-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathrun-test.mjs
More file actions
58 lines (42 loc) · 1.35 KB
/
run-test.mjs
File metadata and controls
58 lines (42 loc) · 1.35 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* eslint-disable no-console */
import { spawn } from 'child_process';
import { execa } from 'execa';
import path from 'path';
// resolved from the root of the project
const inputDir = path.resolve('./test/fixtures/input');
const execOpts = { cwd: inputDir, stderr: 'inherit' };
console.log('installing deps');
await execa('rm', ['-rf', 'node_modules'], execOpts);
await execa('yarn', ['install'], execOpts);
console.log('starting serve');
// We use spawn for this one so we can kill it later without throwing an error
const emberServe = spawn('yarn', ['start'], execOpts);
emberServe.stderr.pipe(process.stderr);
emberServe.stdout.pipe(process.stdout);
await new Promise((resolve) => {
emberServe.stdout.on('data', (data) => {
if (data.toString().includes('Build successful')) {
resolve();
}
});
});
console.log('running codemod');
const codemod = execa(
'../../../bin/cli.js',
['--telemetry', 'http://localhost:4200', 'app'],
execOpts
);
codemod.stdout.pipe(process.stdout);
await codemod;
console.log('codemod complete, ending serve');
emberServe.kill('SIGTERM');
console.log('comparing results');
try {
await execa('diff', ['-rq', './app', '../output/app'], execOpts);
} catch (e) {
console.error('codemod did not run successfully');
console.log(e);
process.exit(1);
}
console.log('codemod ran successfully! 🎉');
process.exit(0);