Skip to content

Commit 5e2b3e9

Browse files
committed
Convert test launcher to javascript
1 parent 2d3bf7d commit 5e2b3e9

File tree

9 files changed

+443
-286
lines changed

9 files changed

+443
-286
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"install": "scripts/install.mjs --force",
99
"lint": "scripts/install.mjs && scripts/lint.mjs",
1010
"start": "SKIP_E2E_DEPS=true scripts/install.mjs && scripts/start.mjs",
11-
"test": "scripts/install.mjs && scripts/lint.mjs && scripts/test.sh",
11+
"test": "scripts/install.mjs && scripts/lint.mjs && scripts/test.mjs",
1212
"format": "npm --prefix=backend run format --quiet && npm --prefix=frontend run format --quiet && npm --prefix=e2e run format --quiet",
1313
"test:backend": "npm --prefix=backend test --quiet --",
1414
"test:frontend": "npm --prefix=frontend test --quiet --",
1515
"test:frontend:watch": "npm --prefix=frontend test --quiet -- --watch",
16-
"test:e2e": "scripts/install.mjs && scripts/e2e.sh"
16+
"test:e2e": "scripts/install.mjs && scripts/test.mjs --only-e2e"
1717
}
1818
}

scripts/build.mjs

+15-26
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
copy,
1313
} from './helpers/io.mjs';
1414
import { stat, rename, chmod } from 'node:fs/promises';
15-
import { runTask, runTaskPrefixOutput } from './helpers/proc.mjs';
15+
import { runMultipleTasks, runTask } from './helpers/proc.mjs';
1616

1717
const PARALLEL_BUILD = (process.env['PARALLEL_BUILD'] ?? 'true') === 'true';
1818
const KEEP_DEPS = process.argv.slice(2).includes('--keep-deps');
@@ -24,39 +24,28 @@ const packages = [
2424
const builddir = join(basedir, 'build');
2525
const staticdir = join(builddir, 'static');
2626

27-
try {
28-
await runTask('diff', [
27+
await runTask({
28+
command: 'diff',
29+
args: [
2930
join(basedir, 'frontend', 'src', 'shared', 'api-entities.ts'),
3031
join(basedir, 'backend', 'src', 'shared', 'api-entities.ts'),
31-
]);
32-
} catch {
33-
log('Shared api-entities.ts files do not match.');
34-
process.exit(1);
35-
}
32+
],
33+
outputMode: 'fail_atomic',
34+
failureMessage: 'Shared api-entities.ts files do not match.',
35+
});
3636

37-
async function buildPackage({ dir, format }) {
38-
log(`Building ${dir}...`);
39-
await runTaskPrefixOutput({
37+
await runMultipleTasks(
38+
packages.map(({ dir, format }) => ({
4039
command: 'npm',
4140
args: ['run', 'build', '--quiet'],
4241
cwd: join(basedir, dir),
42+
beginMessage: `Building ${dir}...`,
43+
failureMessage: `Failed to build ${dir}.`,
4344
outputPrefix: dir,
4445
prefixFormat: format,
45-
});
46-
}
47-
48-
try {
49-
if (PARALLEL_BUILD) {
50-
await Promise.all(packages.map(buildPackage));
51-
} else {
52-
for (const pkg of packages) {
53-
await buildPackage(pkg);
54-
}
55-
}
56-
} catch {
57-
log('Build failed.');
58-
process.exit(1);
59-
}
46+
})),
47+
{ parallel: PARALLEL_BUILD },
48+
);
6049

6150
let preserveBuildModules = false;
6251
const buildModules = join(builddir, 'node_modules');

scripts/e2e.sh

-132
This file was deleted.

0 commit comments

Comments
 (0)