(module)
| 4 | |
| 5 | |
| 6 | function getModulePackageName (module) { |
| 7 | if (!module.context) return null; |
| 8 | const nodeModulesPath = path.join(__dirname, '../node_modules/'); |
| 9 | |
| 10 | if (module.context.substring(0, nodeModulesPath.length) !== nodeModulesPath) { |
| 11 | return null; |
| 12 | } |
| 13 | |
| 14 | const moduleRelativePath = module.context.substring(nodeModulesPath.length); |
| 15 | const [moduleDirName] = moduleRelativePath.split(path.sep); |
| 16 | let packageName = moduleDirName; // handle tree shaking |
| 17 | |
| 18 | if (packageName && packageName.match('^_')) { |
| 19 | // eslint-disable-next-line prefer-destructuring |
| 20 | packageName = packageName.match(/^_(@?[^@]+)/)[1]; |
| 21 | } |
| 22 | |
| 23 | return packageName; |
| 24 | } |
| 25 | |
| 26 | |
| 27 |
no outgoing calls
no test coverage detected