Skip to content

Commit 28888eb

Browse files
committed
feat(build): include the build step as a pretest script instead of inline in the test script
1 parent 2478fa5 commit 28888eb

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/package/scripts/test-script-updater.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ function projectShouldBeBuiltForVerification(scripts) {
99
export default function (scripts) {
1010
return {
1111
...scripts,
12-
test: `npm-run-all --print-label${
13-
projectShouldBeBuiltForVerification(scripts) ? ' build' : ''
14-
} --parallel lint:*${
15-
projectWillBeTested(scripts) ? ' --parallel test:*' : ''
16-
}`
12+
...projectShouldBeBuiltForVerification(scripts) && {pretest: 'run-s build'},
13+
test: `npm-run-all --print-label --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
1714
};
1815
}

src/package/scripts/test-script-updater.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ describe('test script updater', () => {
1414
expect(updateTestScript({...scripts, 'pregenerate:md': 'run-s build'})).toEqual({
1515
...scripts,
1616
'pregenerate:md': 'run-s build',
17-
test: 'npm-run-all --print-label build --parallel lint:*'
17+
pretest: 'run-s build',
18+
test: 'npm-run-all --print-label --parallel lint:*'
1819
});
1920
});
2021

test/integration/features/step_definitions/npm-steps.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ export async function assertThatPackageDetailsAreConfiguredCorrectlyFor({
9494
const packageDetails = JSON.parse(await fs.readFile(`${projectRoot}/package.json`, 'utf-8'));
9595

9696
if (tested && projectTypes.PACKAGE === projectType && provideExample && dialects.COMMON_JS !== dialect) {
97-
assert.equal(packageDetails.scripts.test, 'npm-run-all --print-label build --parallel lint:* --parallel test:*');
97+
assert.equal(packageDetails.scripts.pretest, 'run-s build');
98+
assert.equal(packageDetails.scripts.test, 'npm-run-all --print-label --parallel lint:* --parallel test:*');
9899
} else if (tested) {
100+
assert.isUndefined(packageDetails.scripts.pretest);
99101
assert.equal(packageDetails.scripts.test, 'npm-run-all --print-label --parallel lint:* --parallel test:*');
100102
} else {
103+
assert.isUndefined(packageDetails.scripts.pretest);
101104
assert.equal(packageDetails.scripts.test, 'npm-run-all --print-label --parallel lint:*');
102105
}
103106

test/integration/features/step_definitions/scripts-steps.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Then('the script is added for ensuring the node engines requirement is met', asy
5858
});
5959

6060
Then('the updated test script includes build', async function () {
61-
const {scripts: {test}} = JSON.parse(await fs.readFile(`${process.cwd()}/package.json`, 'utf8'));
61+
const {scripts: {pretest, test}} = JSON.parse(await fs.readFile(`${process.cwd()}/package.json`, 'utf8'));
6262

63-
assert.include(test, 'build');
63+
assert.equal(pretest, 'run-s build');
64+
assert.notInclude(test, 'build');
6465
});

0 commit comments

Comments
 (0)