Skip to content

Commit 3e7ac06

Browse files
committed
[added] '--skip-test(s)' flag
1 parent 347e595 commit 3e7ac06

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

src/release.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const yargsConf = yargs
6161
.example('$0 major', 'Without "--run" option it will dry run')
6262
.example('$0 --preid alpha --run', 'Release same version with pre-release bump. (npm tag `alpha`)')
6363
.example('$0 0.101.0 --preid rc --tag canary --run', 'Release `v0.101.0-rc.0` pre-release version with npm tag `canary`')
64+
.example('$0 ... --skip-test(s)', 'Use this flag in case you need to skip `npm run test` step.')
6465
.command('patch --run', 'Release patch')
6566
.command('minor --run', 'Release minor')
6667
.command('major --run', 'Release major')
@@ -97,6 +98,12 @@ const yargsConf = yargs
9798
default: false,
9899
describe: 'Increased debug output'
99100
})
101+
.option('skip-tests', {
102+
alias: 'skip-test',
103+
demand: false,
104+
default: false,
105+
describe: 'Skip `npm run test` step'
106+
})
100107
.option('notes', {
101108
demand: false,
102109
default: false,
@@ -242,29 +249,33 @@ function release({ type, preid, npmTagName }) {
242249
console.log('Version changed from '.cyan + oldVersion.green + ' to '.cyan + newVersion.green);
243250
safeRun('git add package.json');
244251

245-
// npm run test
246-
// this step is placed after version bumping
247-
// for the case when documents are been built in "npm run test" script
248-
console.log('Running: '.cyan + '"npm run test"'.green);
249-
config.silent = !skipBuildStep;
250-
runAndGitRevertOnError('npm run test');
251-
config.silent = !argv.verbose;
252-
console.log('Completed: '.cyan + '"npm run test"'.green);
253-
254-
// npm run build
255-
if (argv.onlyDocs && docsBuild) {
256-
console.log('Running: '.cyan + 'docs-build'.green);
257-
runAndGitRevertOnError('npm run docs-build');
258-
console.log('Completed: '.cyan + 'docs-build'.green);
259-
} else {
260-
if (npmjson.scripts && npmjson.scripts.build && !skipBuildStep) {
261-
console.log('Running: '.cyan + 'build'.green);
262-
runAndGitRevertOnError('npm run build');
263-
console.log('Completed: '.cyan + 'build'.green);
252+
if (npmjson.scripts) { // do not throw if there are no 'scripts' at all
253+
if (npmjson.scripts.test && !argv.skipTests) {
254+
// npm run test
255+
// this step is placed after version bumping
256+
// for the case when documents are been built in "npm run test" script
257+
console.log('Running: '.cyan + '"npm run test"'.green);
258+
config.silent = !skipBuildStep;
259+
runAndGitRevertOnError('npm run test');
260+
config.silent = !argv.verbose;
261+
console.log('Completed: '.cyan + '"npm run test"'.green);
262+
}
263+
264+
// npm run build
265+
if (argv.onlyDocs && docsBuild) {
266+
console.log('Running: '.cyan + 'docs-build'.green);
267+
runAndGitRevertOnError('npm run docs-build');
268+
console.log('Completed: '.cyan + 'docs-build'.green);
264269
} else {
265-
console.log('Skipping "npm run build" step.'.yellow);
270+
if (npmjson.scripts.build && !skipBuildStep) {
271+
console.log('Running: '.cyan + 'build'.green);
272+
runAndGitRevertOnError('npm run build');
273+
console.log('Completed: '.cyan + 'build'.green);
274+
} else {
275+
console.log('Skipping "npm run build" step.'.yellow);
276+
}
266277
}
267-
}
278+
} // if (npmjson.scripts)
268279

269280
const vVersion = `v${newVersion}`;
270281
const versionAndNotes = notesForRelease = notesForRelease ? `${vVersion} ${notesForRelease}` : vVersion;

0 commit comments

Comments
 (0)