@@ -5,24 +5,29 @@ const $ = require('gulp-load-plugins')()
5
5
const runSequence = require ( 'run-sequence' )
6
6
const semver = require ( 'semver' )
7
7
const fs = require ( 'fs' )
8
- const exec = require ( 'child_process' ) . exec
8
+ const spawn = require ( 'child_process' ) . spawn
9
9
10
10
function getCurrentVersion ( ) {
11
11
return JSON . parse ( fs . readFileSync ( './package.json' , 'utf8' ) ) . version
12
12
}
13
13
14
- function npmPublish ( done ) {
15
- exec ( 'npm publish' , ( err , stdout , stderr ) => {
16
- if ( err ) throw err
17
- $ . util . log ( 'Published to npm' )
18
- } )
19
- }
20
-
21
14
function fail ( msg ) {
22
15
$ . util . log ( $ . util . colors . red ( msg ) )
23
16
process . exit ( 1 )
24
17
}
25
18
19
+ function npmPublish ( done ) {
20
+ const publish = spawn ( 'npm' , [ 'publish' ] )
21
+ publish . stdout . pipe ( process . stdout )
22
+ publish . stderr . pipe ( process . stderr )
23
+ publish . on ( 'close' , code => {
24
+ if ( code !== 0 ) return fail ( `npm publish. Exiting with ${ code } .` )
25
+
26
+ $ . util . log ( 'Published to npm.' )
27
+ done ( )
28
+ } )
29
+ }
30
+
26
31
function getType ( ) {
27
32
if ( $ . util . env . major ) return 'major'
28
33
if ( $ . util . env . minor ) return 'minor'
@@ -51,7 +56,7 @@ gulp.task('release:bump', () => {
51
56
52
57
gulp . task ( 'release:push' , done => {
53
58
const remote = $ . util . remote || 'origin'
54
-
59
+ $ . util . log ( 'Pushing to git...' )
55
60
$ . git . push ( remote , 'master' , { args : '--tags' } , err => {
56
61
if ( err ) return fail ( err . message )
57
62
@@ -70,6 +75,7 @@ gulp.task('release:publish', done => {
70
75
return fail ( 'Dirt workspace, cannot push to npm' )
71
76
}
72
77
78
+ $ . util . log ( 'Publishing to npm...' )
73
79
npmPublish ( done )
74
80
} )
75
81
} )
0 commit comments