-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathrun-all.js
executable file
·36 lines (27 loc) · 1.03 KB
/
run-all.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
31
32
33
34
35
36
#!/usr/bin/env node
/* eslint-disable */
const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');
const baseDir = path.resolve(__dirname);
const packageDir = `${baseDir}/..`;
const yalcBin = `${packageDir}/node_modules/.bin/yalc`;
const exec = (cwd, cmd) => {
console.log(`Running ${cmd} in ${cwd}`);
execSync(cmd, { cwd, encoding: 'utf8' });
};
// Build and "publish" the package locally.
exec(packageDir, `${yalcBin} publish`);
// Run all the example projects.
for (let file of fs.readdirSync(baseDir, { withFileTypes: true })) {
if (file.isDirectory()) {
const exampleDir = `${baseDir}/${file.name}`;
console.log(`Running example "${exampleDir}"`);
exec(exampleDir, 'rm -rf node_modules');
exec(exampleDir, 'npm ci');
// Install the local version of the adapter using yalc, which ensures that
// it behaves the same way as the package installed from npm.
exec(exampleDir, `${yalcBin} link enzyme-adapter-preact-pure`);
exec(exampleDir, 'npm test');
}
}