File tree 4 files changed +26
-8
lines changed
4 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ var argv = require('yargs')
38
38
default : defaults . noVerify ,
39
39
global : true
40
40
} )
41
+ . option ( 'silent' , {
42
+ describe : 'Don\'t print logs and errors' ,
43
+ type : 'boolean' ,
44
+ default : defaults . silent ,
45
+ global : true
46
+ } )
41
47
. help ( )
42
48
. alias ( 'help' , 'h' )
43
49
. example ( '$0' , 'Update changelog and tag release' )
Original file line number Diff line number Diff line change 4
4
"firstRelease" : false ,
5
5
"sign" : false ,
6
6
"noVerify" : false ,
7
+ "silent" : false
7
8
}
Original file line number Diff line number Diff line change @@ -143,16 +143,20 @@ function createIfMissing (argv) {
143
143
}
144
144
145
145
function checkpoint ( argv , msg , args , figure ) {
146
- console . info ( ( figure || chalk . green ( figures . tick ) ) + ' ' + util . format . apply ( util , [ msg ] . concat ( args . map ( function ( arg ) {
147
- return chalk . bold ( arg )
148
- } ) ) ) )
146
+ if ( ! argv . silent ) {
147
+ console . info ( ( figure || chalk . green ( figures . tick ) ) + ' ' + util . format . apply ( util , [ msg ] . concat ( args . map ( function ( arg ) {
148
+ return chalk . bold ( arg )
149
+ } ) ) ) )
150
+ }
149
151
}
150
152
151
153
function printError ( argv , msg , opts ) {
152
- opts = objectAssign ( {
153
- level : 'error' ,
154
- color : 'red'
155
- } , opts )
154
+ if ( ! argv . silent ) {
155
+ opts = objectAssign ( {
156
+ level : 'error' ,
157
+ color : 'red'
158
+ } , opts )
156
159
157
- console [ opts . level ] ( chalk [ opts . color ] ( msg ) )
160
+ console [ opts . level ] ( chalk [ opts . color ] ( msg ) )
161
+ }
158
162
}
Original file line number Diff line number Diff line change @@ -199,6 +199,13 @@ describe('cli', function () {
199
199
execCli ( '-n' ) . code . should . equal ( 0 )
200
200
} )
201
201
202
+ it ( 'does not print output when the --silent flag is passed' , function ( ) {
203
+ var result = execCli ( '--silent' )
204
+ result . code . should . equal ( 0 )
205
+ result . stdout . should . equal ( '' )
206
+ result . stderr . should . equal ( '' )
207
+ } )
208
+
202
209
it ( 'does not display `npm publish` if the package is private' , function ( ) {
203
210
writePackageJson ( '1.0.0' , { private : true } )
204
211
You can’t perform that action at this time.
0 commit comments