Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 7f3b52e

Browse files
committedNov 23, 2015
chore(tasks): Use spawn instead of exec
Fixes #138
1 parent cdb449e commit 7f3b52e

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed
 

‎tasks/release.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,29 @@ const $ = require('gulp-load-plugins')()
55
const runSequence = require('run-sequence')
66
const semver = require('semver')
77
const fs = require('fs')
8-
const exec = require('child_process').exec
8+
const spawn = require('child_process').spawn
99

1010
function getCurrentVersion () {
1111
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version
1212
}
1313

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-
2114
function fail (msg) {
2215
$.util.log($.util.colors.red(msg))
2316
process.exit(1)
2417
}
2518

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+
2631
function getType () {
2732
if ($.util.env.major) return 'major'
2833
if ($.util.env.minor) return 'minor'
@@ -51,7 +56,7 @@ gulp.task('release:bump', () => {
5156

5257
gulp.task('release:push', done => {
5358
const remote = $.util.remote || 'origin'
54-
59+
$.util.log('Pushing to git...')
5560
$.git.push(remote, 'master', {args: '--tags'}, err => {
5661
if (err) return fail(err.message)
5762

@@ -70,6 +75,7 @@ gulp.task('release:publish', done => {
7075
return fail('Dirt workspace, cannot push to npm')
7176
}
7277

78+
$.util.log('Publishing to npm...')
7379
npmPublish(done)
7480
})
7581
})

0 commit comments

Comments
 (0)
This repository has been archived.