File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ var argv = require('yargs')
3838 default : defaults . noVerify ,
3939 global : true
4040 } )
41+ . option ( 'silent' , {
42+ describe : 'Don\'t print logs and errors' ,
43+ type : 'boolean' ,
44+ default : defaults . silent ,
45+ global : true
46+ } )
4147 . help ( )
4248 . alias ( 'help' , 'h' )
4349 . example ( '$0' , 'Update changelog and tag release' )
Original file line number Diff line number Diff line change 44 "firstRelease" : false ,
55 "sign" : false ,
66 "noVerify" : false ,
7+ "silent" : false
78}
Original file line number Diff line number Diff line change @@ -143,16 +143,20 @@ function createIfMissing (argv) {
143143}
144144
145145function 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+ }
149151}
150152
151153function 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 )
156159
157- console [ opts . level ] ( chalk [ opts . color ] ( msg ) )
160+ console [ opts . level ] ( chalk [ opts . color ] ( msg ) )
161+ }
158162}
Original file line number Diff line number Diff line change @@ -199,6 +199,13 @@ describe('cli', function () {
199199 execCli ( '-n' ) . code . should . equal ( 0 )
200200 } )
201201
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+
202209 it ( 'does not display `npm publish` if the package is private' , function ( ) {
203210 writePackageJson ( '1.0.0' , { private : true } )
204211
You can’t perform that action at this time.
0 commit comments