(func)
| 21 | } |
| 22 | |
| 23 | function getPluginName (func) { |
| 24 | const display = getDisplayName(func) |
| 25 | if (display) { |
| 26 | return display |
| 27 | } |
| 28 | |
| 29 | // let's see if this is a file, and in that case use that |
| 30 | // this is common for plugins |
| 31 | const cache = require.cache |
| 32 | // cache is undefined inside SEA |
| 33 | if (cache) { |
| 34 | const keys = Object.keys(cache) |
| 35 | |
| 36 | for (let i = 0; i < keys.length; i++) { |
| 37 | const key = keys[i] |
| 38 | if (cache[key].exports === func) { |
| 39 | return key |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // if not maybe it's a named function, so use that |
| 45 | if (func.name) { |
| 46 | return func.name |
| 47 | } |
| 48 | |
| 49 | return null |
| 50 | } |
| 51 | |
| 52 | function getFuncPreview (func) { |
| 53 | // takes the first two lines of the function if nothing else works |
no test coverage detected