49 lines
1.1 KiB
JavaScript
Executable File
49 lines
1.1 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict'
|
|
|
|
var argv = require('minimist')(process.argv.slice(2), {
|
|
alias: {
|
|
d: 'debug',
|
|
dry: 'debug',
|
|
t: 'token'
|
|
},
|
|
default: {
|
|
token: process.env.GH_TOKEN || process.env.TOKEN || process.env.GITHUB_TOKEN
|
|
}
|
|
})
|
|
|
|
if (~argv._.indexOf('pre')) {
|
|
// The prepublish script is also executed when the package's dependencies are installed
|
|
// In this case we abort the command and do nothing.
|
|
var npmArgv = process.env.npm_config_argv
|
|
if (npmArgv) {
|
|
npmArgv = JSON.parse(npmArgv)
|
|
if (~npmArgv.cooked.indexOf('install')) process.exit(0)
|
|
}
|
|
|
|
console.log('Determining new version')
|
|
|
|
return require('../src/pre')(argv, function (err, result) {
|
|
if (err) {
|
|
console.log('Something went wrong.')
|
|
throw err
|
|
}
|
|
|
|
if (!result) {
|
|
console.log('Nothing changed. Not publishing.')
|
|
process.exit(1)
|
|
}
|
|
|
|
console.log('Publishing v' + result)
|
|
})
|
|
}
|
|
|
|
if (~argv._.indexOf('post')) {
|
|
return require('../src/post')(argv, function (err) {
|
|
if (err) {
|
|
console.log('Something went wrong.')
|
|
throw err
|
|
}
|
|
})
|
|
}
|