Skip to content

Commit ac415b1

Browse files
committed
build_changed.ts/test_changed.ts: replace process.exit() with just letting the exception bubble up, to avoid truncating output
1 parent db74abf commit ac415b1

File tree

2 files changed

+51
-62
lines changed

2 files changed

+51
-62
lines changed

scripts/ci-test/build_changed.ts

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,36 @@ async function buildForTests(
6363
config: TestConfig,
6464
{ buildAll = false }: Options
6565
) {
66-
try {
67-
const testTasks = filterTasks(await getTestTasks(), config);
68-
// print tasks for info
69-
logTasks(testTasks);
70-
if (testTasks.length === 0) {
71-
console.log(chalk`{green No test tasks. Skipping all builds }`);
72-
return;
73-
}
66+
const testTasks = filterTasks(await getTestTasks(), config);
67+
// print tasks for info
68+
logTasks(testTasks);
69+
if (testTasks.length === 0) {
70+
console.log(chalk`{green No test tasks. Skipping all builds }`);
71+
return;
72+
}
7473

75-
// build all and return
76-
if (buildAll) {
77-
await spawn('yarn', ['build'], { stdio: 'inherit', cwd: root });
78-
return;
79-
}
74+
// build all and return
75+
if (buildAll) {
76+
await spawn('yarn', ['build'], { stdio: 'inherit', cwd: root });
77+
return;
78+
}
8079

81-
const lernaCmd = ['lerna', 'run'];
82-
console.log(chalk`{blue Running build in:}`);
83-
for (const task of testTasks) {
84-
if (task.reason === TestReason.Changed) {
85-
console.log(chalk`{yellow ${task.pkgName} (contains modified files)}`);
86-
} else if (task.reason === TestReason.Dependent) {
87-
console.log(
88-
chalk`{yellow ${task.pkgName} (depends on modified files)}`
89-
);
90-
} else {
91-
console.log(chalk`{yellow ${task.pkgName} (running all tests)}`);
92-
}
93-
lernaCmd.push('--scope');
94-
lernaCmd.push(task.pkgName);
80+
const lernaCmd = ['lerna', 'run'];
81+
console.log(chalk`{blue Running build in:}`);
82+
for (const task of testTasks) {
83+
if (task.reason === TestReason.Changed) {
84+
console.log(chalk`{yellow ${task.pkgName} (contains modified files)}`);
85+
} else if (task.reason === TestReason.Dependent) {
86+
console.log(
87+
chalk`{yellow ${task.pkgName} (depends on modified files)}`
88+
);
89+
} else {
90+
console.log(chalk`{yellow ${task.pkgName} (running all tests)}`);
9591
}
96-
97-
lernaCmd.push('--include-dependencies', 'build');
98-
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
99-
} catch (e) {
100-
console.error(chalk`{red ${e}}`);
101-
process.exit(1);
92+
lernaCmd.push('--scope');
93+
lernaCmd.push(task.pkgName);
10294
}
95+
96+
lernaCmd.push('--include-dependencies', 'build');
97+
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
10398
}

scripts/ci-test/test_changed.ts

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,31 @@ const config = testConfig[inputTestConfigName]!;
4949
runTests(config);
5050

5151
async function runTests(config: TestConfig) {
52-
try {
53-
const testTasks = filterTasks(await getTestTasks(), config);
52+
const testTasks = filterTasks(await getTestTasks(), config);
5453

55-
// print tasks for info
56-
logTasks(testTasks);
57-
if (testTasks.length === 0) {
58-
chalk`{green No test tasks. Skipping all tests }`;
59-
process.exit(0);
60-
}
54+
// print tasks for info
55+
logTasks(testTasks);
56+
if (testTasks.length === 0) {
57+
chalk`{green No test tasks. Skipping all tests }`;
58+
process.exit(0);
59+
}
6160

62-
const lernaCmd = ['lerna', 'run', '--concurrency', '4'];
63-
console.log(chalk`{blue Running tests in:}`);
64-
for (const task of testTasks) {
65-
if (task.reason === TestReason.Changed) {
66-
console.log(chalk`{yellow ${task.pkgName} (contains modified files)}`);
67-
} else if (task.reason === TestReason.Dependent) {
68-
console.log(
69-
chalk`{yellow ${task.pkgName} (depends on modified files)}`
70-
);
71-
} else {
72-
console.log(chalk`{yellow ${task.pkgName} (running all tests)}`);
73-
}
74-
lernaCmd.push('--scope');
75-
lernaCmd.push(task.pkgName);
61+
const lernaCmd = ['lerna', 'run', '--concurrency', '4'];
62+
console.log(chalk`{blue Running tests in:}`);
63+
for (const task of testTasks) {
64+
if (task.reason === TestReason.Changed) {
65+
console.log(chalk`{yellow ${task.pkgName} (contains modified files)}`);
66+
} else if (task.reason === TestReason.Dependent) {
67+
console.log(
68+
chalk`{yellow ${task.pkgName} (depends on modified files)}`
69+
);
70+
} else {
71+
console.log(chalk`{yellow ${task.pkgName} (running all tests)}`);
7672
}
77-
78-
lernaCmd.push(testCommand);
79-
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
80-
process.exit(0);
81-
} catch (e) {
82-
console.error(chalk`{red ${e}}`);
83-
process.exit(1);
73+
lernaCmd.push('--scope');
74+
lernaCmd.push(task.pkgName);
8475
}
76+
77+
lernaCmd.push(testCommand);
78+
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
8579
}

0 commit comments

Comments
 (0)