-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-p-map.js
30 lines (26 loc) · 890 Bytes
/
test-p-map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pMap from 'p-map';
import { exec } from 'child_process';
import { promisify } from 'util';
import { readdir } from 'fs/promises';
const execAsync = promisify(exec);
async function getPackages() {
const dirs = await readdir('./packages', { withFileTypes: true });
return dirs.filter(dir => dir.isDirectory()).map(dir => `./packages/${dir.name}`);
}
async function runTests() {
const packages = await getPackages();
await pMap(
packages,
async (pkg) => {
console.log(`Running tests in ${pkg}`);
try {
await execAsync(`npm test`, { cwd: pkg });
console.log(`✅ ${pkg} passed`);
} catch (error) {
console.error(`❌ ${pkg} failed`);
}
},
{ concurrency: 10 } // Adjust concurrency level as needed
);
}
runTests().catch(console.error);