1
1
/* eslint no-process-exit: 0 */
2
2
import yargs from 'yargs' ;
3
- import { exec } from 'child-process-promise ' ;
3
+ import { exec , safeExec , setExecOptions } from '../exec ' ;
4
4
5
5
import preConditions from './pre-conditions' ;
6
6
import versionBump from './version-bump' ;
@@ -10,12 +10,13 @@ import tagAndPublish from './tag-and-publish';
10
10
import test from './test' ;
11
11
import build from '../build' ;
12
12
13
- import { repoRoot , bowerRepo , bowerRoot , tmpBowerRepo , docsRoot , docsRepo , tmpDocsRepo } from './constants' ;
13
+ import { repoRoot , bowerRepo , bowerRoot , tmpBowerRepo , docsRoot , docsRepo , tmpDocsRepo } from '.. /constants' ;
14
14
15
15
const yargsConf = yargs
16
16
. usage ( 'Usage: $0 <version> [--preid <identifier>]' )
17
17
. example ( '$0 minor --preid beta' , 'Release with minor version bump with pre-release tag' )
18
18
. example ( '$0 major' , 'Release with major version bump' )
19
+ . example ( '$0 major --dry-run' , 'Release dry run with patch version bump' )
19
20
. example ( '$0 --preid beta' , 'Release same version with pre-release bump' )
20
21
. command ( 'patch' , 'Release patch' )
21
22
. command ( 'minor' , 'Release minor' )
@@ -25,9 +26,21 @@ const yargsConf = yargs
25
26
demand : false ,
26
27
describe : 'pre-release identifier' ,
27
28
type : 'string'
29
+ } )
30
+ . option ( 'dry-run' , {
31
+ alias : 'n' ,
32
+ demand : false ,
33
+ default : false ,
34
+ describe : 'Execute command in dry run mode. Will not commit, tag, push, or publish anything. Userful for testing.'
35
+ } )
36
+ . option ( 'verbose' , {
37
+ demand : false ,
38
+ default : false ,
39
+ describe : 'Increased debug output'
28
40
} ) ;
29
41
30
42
const argv = yargsConf . argv ;
43
+ setExecOptions ( argv ) ;
31
44
32
45
let version ;
33
46
@@ -61,7 +74,7 @@ preConditions()
61
74
} ) ;
62
75
} ) ;
63
76
} )
64
- . then ( ( ) => exec ( `git commit -m "Release v${ version } "` ) )
77
+ . then ( ( ) => safeExec ( `git commit -m "Release v${ version } "` ) )
65
78
. then ( ( ) => Promise . all ( [
66
79
tagAndPublish ( version ) ,
67
80
repoRelease ( bowerRepo , bowerRoot , tmpBowerRepo , version ) ,
@@ -70,7 +83,11 @@ preConditions()
70
83
. then ( ( ) => console . log ( 'Version ' . cyan + `v${ version } ` . green + ' released!' . cyan ) )
71
84
. catch ( err => {
72
85
if ( ! err . __handled ) {
73
- console . error ( err . message . red ) ;
86
+ if ( argv . verbose ) {
87
+ console . error ( err . stack . red ) ;
88
+ } else {
89
+ console . error ( err . toString ( ) . red ) ;
90
+ }
74
91
}
75
92
76
93
process . exit ( 1 ) ;
0 commit comments