Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2c701ca1b | ||
|
|
b39fecbdc2 | ||
|
|
f7faebb175 |
@@ -17,7 +17,7 @@ For maximum comfort you can automate this inside your `package.json`:
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"prepublish": "semantic-release pre"
|
||||
"prepublish": "semantic-release pre",
|
||||
"postpublish": "semantic-release post"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -43,7 +43,14 @@ if (~argv._.indexOf('pre')) {
|
||||
}
|
||||
|
||||
console.log('Publishing v' + result)
|
||||
if (publish) require('../src/restart')()
|
||||
if (publish) require('../src/restart')(function (err) {
|
||||
if (err) {
|
||||
console.log('Something went wrong.')
|
||||
throw err
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -59,14 +66,13 @@ if (~argv._.indexOf('post')) {
|
||||
// see src/restart.js
|
||||
if (~npmArgv.indexOf('--semantic-release-rerun')) {
|
||||
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function confirmCI (cb) {
|
||||
if (process.env.CI) return cb(null, true)
|
||||
if (process.env.CI || argv.ci === false) return cb(null, true)
|
||||
|
||||
confirm('Not running in a CI enviroment. Are you sure you want to run this hook?', function (ok) {
|
||||
if (!ok) process.exit(1)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "semantic-release",
|
||||
"description": "semantic semver compliant package publishing",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.5",
|
||||
"author": "Stephan Bönnemann <stephan@boennemann.me>",
|
||||
"bin": "./bin/semantic-release",
|
||||
"bugs": {
|
||||
|
||||
+15
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
var spawn = require('child_process').spawn
|
||||
|
||||
module.exports = function () {
|
||||
var exports = module.exports = function (cb) {
|
||||
// npm loads package.json data before running the `prepublish` hook
|
||||
// changing the version on `prepublish` has no effect
|
||||
// see https://github.com/npm/npm/issues/7118
|
||||
@@ -10,7 +10,21 @@ module.exports = function () {
|
||||
// the package.json is then loaded again and the correct version will be published
|
||||
|
||||
var child = spawn('npm', ['publish', '--semantic-release-rerun'])
|
||||
var handler = exports.handleCloseAndExit.bind(null, cb)
|
||||
|
||||
child.stdout.pipe(process.stdout)
|
||||
child.stderr.pipe(process.stderr)
|
||||
|
||||
child.on('close', handler)
|
||||
child.on('exit', handler)
|
||||
child.on('error', cb)
|
||||
}
|
||||
|
||||
exports.handleCloseAndExit = function (cb, code, signal) {
|
||||
if (code === 0) return cb(null)
|
||||
cb({
|
||||
code: code,
|
||||
signal: signal,
|
||||
message: 'npm publish failed'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user