* Check if the dist files contain browser-incompatible imports
(packageDir)
| 137 | * Check if the dist files contain browser-incompatible imports |
| 138 | */ |
| 139 | function checkDistForNodeProtocol(packageDir) { |
| 140 | const distDir = join(packageDir, 'dist'); |
| 141 | if (!existsSync(distDir)) { |
| 142 | return { ok: true, issues: [] }; |
| 143 | } |
| 144 | |
| 145 | const issues = []; |
| 146 | const jsFiles = findJsFiles(distDir); |
| 147 | |
| 148 | for (const filePath of jsFiles) { |
| 149 | const content = readFileSync(filePath, 'utf8'); |
| 150 | for (const pattern of BROWSER_INCOMPATIBLE_PATTERNS) { |
| 151 | if (pattern.test(content)) { |
| 152 | issues.push({ |
| 153 | file: filePath.replace(ROOT_DIR, ''), |
| 154 | pattern: pattern.toString(), |
| 155 | }); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | return { ok: issues.length === 0, issues }; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Test that a package can be packed without errors |
no test coverage detected