-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccept.spec.ts
40 lines (38 loc) · 2.14 KB
/
accept.spec.ts
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
37
38
39
40
import { sync as spawnSync } from 'cross-spawn';
import fs from 'fs';
import path from 'path';
export = fs.readdirSync(__dirname)
.filter(source => fs.lstatSync(path.join(__dirname, source)).isDirectory())
.filter(project => project !== 'scaffolded-project')
.map(project => {
const cwd = path.resolve(__dirname, `./${project}`);
const testProccess = spawnSync('npm', ['test'], { cwd, encoding: 'utf8' });
const acceptProccess = spawnSync('npm', ['run', 'accept'], { cwd, encoding: 'utf8' });
return {
project,
test: {
stdout: testProccess.stdout.split('\n')
// we don't need to check npm tasks output (like `> baset` or `> path/to/node.exe index.js`)
.filter(line => !line.startsWith('>'))
.filter(line => !line.startsWith('PixiJS'))
.map(line => line
.replace(/\(.*m?s\)/, '') // we don't need timing output from `tap-diff` here
.replace(/(✔|√)/, ' ')), // `tap-diff` has different signs on win and *nix
stderr: testProccess.stderr.split('\n')
// we don't need to check npm warn about node version used in script
.filter(line => !line.search('`--scripts-prepend-node-path`')),
},
accept: {
stdout: acceptProccess.stdout.split('\n')
// we don't need to check npm tasks output (like `> baset` or `> path/to/node.exe index.js`)
.filter(line => !line.startsWith('>'))
.filter(line => !line.startsWith('PixiJS'))
.map(line => line
.replace(/\(.*m?s\)/, '') // we don't need timing output from `tap-diff` here
.replace(/(✔|√)/, ' ')), // `tap-diff` has different signs on win and *nix
stderr: acceptProccess.stderr.split('\n')
// we don't need to check npm warn about node version used in script
.filter(line => !line.search('`--scripts-prepend-node-path`')),
},
};
});