|
1 |
| -import globby from 'globby'; |
2 |
| -import { dirname } from 'path'; |
3 |
| -import { fileURLToPath } from 'url'; |
4 |
| -import chalk from 'chalk'; |
5 |
| - |
6 |
| -async function main() { |
7 |
| - const mjsFiles = await globby(['../packages/*/dist/*.mjs'], { |
8 |
| - cwd: dirname(fileURLToPath(import.meta.url)), |
9 |
| - }); |
10 |
| - |
11 |
| - const ok = []; |
12 |
| - const fail = []; |
13 |
| - |
14 |
| - let i = 0; |
15 |
| - await Promise.all( |
16 |
| - mjsFiles.map((mjsFile) => { |
17 |
| - const mjsPath = `./${mjsFile}`; |
18 |
| - return import(mjsPath) |
19 |
| - .then(() => { |
20 |
| - ok.push(mjsPath); |
21 |
| - }) |
22 |
| - .catch((err) => { |
23 |
| - const color = i++ % 2 === 0 ? chalk.magenta : chalk.red; |
24 |
| - console.error(color('\n\n-----\n' + i + '\n')); |
25 |
| - console.error(mjsPath, err); |
26 |
| - console.error(color('\n-----\n\n')); |
27 |
| - fail.push(mjsPath); |
28 |
| - }); |
29 |
| - }) |
30 |
| - ); |
31 |
| - ok.length && console.log(chalk.blue(`${ok.length} OK: ${ok.join(' | ')}`)); |
32 |
| - fail.length && |
33 |
| - console.error(chalk.red(`${fail.length} Fail: ${fail.join(' | ')}`)); |
34 |
| - |
35 |
| - if (fail.length) { |
36 |
| - console.error('\nFAILED'); |
37 |
| - process.exit(1); |
38 |
| - } else if (ok.length) { |
39 |
| - console.error('\nOK'); |
40 |
| - process.exit(0); |
41 |
| - } else { |
42 |
| - console.error('No files analyzed!'); |
43 |
| - process.exit(1); |
44 |
| - } |
45 |
| -} |
46 |
| - |
47 |
| -main().catch((err) => { |
48 |
| - console.error(err); |
49 |
| - process.exit(1); |
50 |
| -}); |
| 1 | +import { globby } from 'globby'; |
| 2 | +import { dirname } from 'path'; |
| 3 | +import { fileURLToPath } from 'url'; |
| 4 | +import chalk from 'chalk'; |
| 5 | + |
| 6 | +async function main() { |
| 7 | + const mjsFiles = await globby(['../packages/*/dist/*.mjs'], { |
| 8 | + cwd: dirname(fileURLToPath(import.meta.url)), |
| 9 | + }); |
| 10 | + |
| 11 | + const ok = []; |
| 12 | + const fail = []; |
| 13 | + |
| 14 | + let i = 0; |
| 15 | + await Promise.all( |
| 16 | + mjsFiles.map((mjsFile) => { |
| 17 | + const mjsPath = `./${mjsFile}`; |
| 18 | + return import(mjsPath) |
| 19 | + .then(() => { |
| 20 | + ok.push(mjsPath); |
| 21 | + }) |
| 22 | + .catch((err) => { |
| 23 | + const color = i++ % 2 === 0 ? chalk.magenta : chalk.red; |
| 24 | + console.error(color('\n\n-----\n' + i + '\n')); |
| 25 | + console.error(mjsPath, err); |
| 26 | + console.error(color('\n-----\n\n')); |
| 27 | + fail.push(mjsPath); |
| 28 | + }); |
| 29 | + }) |
| 30 | + ); |
| 31 | + ok.length && console.log(chalk.blue(`${ok.length} OK: ${ok.join(' | ')}`)); |
| 32 | + fail.length && |
| 33 | + console.error(chalk.red(`${fail.length} Fail: ${fail.join(' | ')}`)); |
| 34 | + |
| 35 | + if (fail.length) { |
| 36 | + console.error('\nFAILED'); |
| 37 | + process.exit(1); |
| 38 | + } else if (ok.length) { |
| 39 | + console.error('\nOK'); |
| 40 | + process.exit(0); |
| 41 | + } else { |
| 42 | + console.error('No files analyzed!'); |
| 43 | + process.exit(1); |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +main().catch((err) => { |
| 48 | + console.error(err); |
| 49 | + process.exit(1); |
| 50 | +}); |
0 commit comments