@@ -61,6 +61,7 @@ const yargsConf = yargs
61
61
. example ( '$0 major' , 'Without "--run" option it will dry run' )
62
62
. example ( '$0 --preid alpha --run' , 'Release same version with pre-release bump. (npm tag `alpha`)' )
63
63
. 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.' )
64
65
. command ( 'patch --run' , 'Release patch' )
65
66
. command ( 'minor --run' , 'Release minor' )
66
67
. command ( 'major --run' , 'Release major' )
@@ -97,6 +98,12 @@ const yargsConf = yargs
97
98
default : false ,
98
99
describe : 'Increased debug output'
99
100
} )
101
+ . option ( 'skip-tests' , {
102
+ alias : 'skip-test' ,
103
+ demand : false ,
104
+ default : false ,
105
+ describe : 'Skip `npm run test` step'
106
+ } )
100
107
. option ( 'notes' , {
101
108
demand : false ,
102
109
default : false ,
@@ -242,29 +249,33 @@ function release({ type, preid, npmTagName }) {
242
249
console . log ( 'Version changed from ' . cyan + oldVersion . green + ' to ' . cyan + newVersion . green ) ;
243
250
safeRun ( 'git add package.json' ) ;
244
251
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 ) ;
264
269
} 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
+ }
266
277
}
267
- }
278
+ } // if (npmjson.scripts)
268
279
269
280
const vVersion = `v${ newVersion } ` ;
270
281
const versionAndNotes = notesForRelease = notesForRelease ? `${ vVersion } ${ notesForRelease } ` : vVersion ;
0 commit comments