(mod)
| 13 | // - existing source file name |
| 14 | // - the path leading up to **just** the package (not including subpath). |
| 15 | function _formatFileName(mod) { |
| 16 | const { fileName, baseName } = mod; |
| 17 | |
| 18 | // Source file. |
| 19 | if (!baseName) { |
| 20 | return `{green-fg}.${sep}${relative(process.cwd(), resolve(fileName))}{/}`; |
| 21 | } |
| 22 | |
| 23 | // Package |
| 24 | let parts = fileName.split(sep); |
| 25 | // Remove starting path. |
| 26 | const firstNmIdx = parts.indexOf("node_modules"); |
| 27 | parts = parts.slice(firstNmIdx); |
| 28 | |
| 29 | // Remove trailing path after package. |
| 30 | const lastNmIdx = parts.lastIndexOf("node_modules"); |
| 31 | const isScoped = (parts[lastNmIdx + 1] || "").startsWith("@"); |
| 32 | parts = parts.slice(0, lastNmIdx + (isScoped ? 3 : 2)); // eslint-disable-line no-magic-numbers |
| 33 | |
| 34 | return parts.map(part => (part === "node_modules" ? "~" : `{yellow-fg}${part}{/}`)).join(sep); |
| 35 | } |
| 36 | |
| 37 | function _formatPercentage(modSize, assetSize) { |
| 38 | const percentage = ((modSize / assetSize) * PERCENT_MULTIPLIER).toPrecision(PERCENT_PRECISION); |
no outgoing calls
no test coverage detected
searching dependent graphs…