chore: allow es6 in src, wile keeping every commit addressable
This commit is contained in:
parent
1db531b511
commit
1f3c5e885e
@ -1,13 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
|
||||
var readFile = require('fs').readFileSync
|
||||
|
||||
var abbrev = require('abbrev')
|
||||
var minimist = require('minimist')
|
||||
|
||||
var efh = require('../lib/error').standard
|
||||
|
||||
var argv = minimist(process.argv.slice(2), {
|
||||
alias: {
|
||||
d: 'debug',
|
||||
@ -23,72 +19,25 @@ var argv = minimist(process.argv.slice(2), {
|
||||
}
|
||||
})
|
||||
|
||||
var plugins = JSON.parse(readFile('./package.json')).release || {}
|
||||
|
||||
var npmArgv = process.env.npm_config_argv ?
|
||||
minimist(JSON.parse(process.env.npm_config_argv).cooked) :
|
||||
{_: []}
|
||||
|
||||
var plugins = JSON.parse(readFile('./package.json')).release || {}
|
||||
|
||||
var main
|
||||
|
||||
try {
|
||||
main = require('../dist/main')
|
||||
} catch (e) {
|
||||
require('babel/register')
|
||||
main = require('../src/main')
|
||||
}
|
||||
|
||||
if (~argv._.indexOf('pre')) {
|
||||
// see src/restart.js
|
||||
if (npmArgv['semantic-release-rerun']) {
|
||||
if (!/semantically-released/.test(process.env.npm_package_version)) process.exit(0)
|
||||
|
||||
console.log('There is something wrong with your setup, as a placeholder version is about to be released.')
|
||||
console.log('Please verify that your setup is correct.')
|
||||
console.log('If you think this is a problem with semantic-release please open an issue.')
|
||||
process.exit(1)
|
||||
}
|
||||
// the `prepublish` hook is also executed when the package is installed
|
||||
// in this case we abort the command and do nothing.
|
||||
if (
|
||||
isAbbrev(npmArgv, 'install') ||
|
||||
isAbbrev(npmArgv, 'link') ||
|
||||
isAbbrev(npmArgv, 'pack')
|
||||
) process.exit(0)
|
||||
|
||||
if (argv.debug) console.log('This is a dry run')
|
||||
|
||||
console.log('Determining new version')
|
||||
|
||||
var publish = false
|
||||
if (isAbbrev(npmArgv, 'publish')) publish = true
|
||||
|
||||
// require a correct setup during publish
|
||||
if (publish && !argv.debug && !require('../src/verify')(argv)) process.exit(1)
|
||||
|
||||
require('../src/pre')(argv, plugins, efh(function (result) {
|
||||
if (!result) {
|
||||
console.log('Nothing changed. Not publishing.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('Publishing v' + result)
|
||||
if (!publish) process.exit(0)
|
||||
|
||||
if (argv.debug) process.exit(1)
|
||||
|
||||
require('../src/restart')(efh(function () {
|
||||
process.exit(1)
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
if (~argv._.indexOf('post')) {
|
||||
require('../src/post')(argv, plugins, efh(function () {
|
||||
// see src/restart.js
|
||||
if (npmArgv['semantic-release-rerun']) {
|
||||
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
if (~argv._.indexOf('setup')) {
|
||||
require('../src/setup')()
|
||||
console.log('"package.json" is set up properly. Now configure your CI server.')
|
||||
console.log('https://github.com/boennemann/semantic-release#ci-server')
|
||||
}
|
||||
|
||||
function isAbbrev (argv, command) {
|
||||
return argv._.some(Object.prototype.hasOwnProperty.bind(abbrev(command)))
|
||||
main.pre(argv, npmArgv, plugins)
|
||||
} else if (~argv._.indexOf('post')) {
|
||||
main.post(argv, npmArgv, plugins)
|
||||
} else if (~argv._.indexOf('setup')) {
|
||||
main.setup(argv, npmArgv, plugins)
|
||||
}
|
||||
|
21
package.json
21
package.json
@ -43,16 +43,22 @@
|
||||
"keywords": [
|
||||
"author",
|
||||
"automation",
|
||||
"release",
|
||||
"publish",
|
||||
"changelog",
|
||||
"module",
|
||||
"package",
|
||||
"publish",
|
||||
"release",
|
||||
"semver",
|
||||
"version",
|
||||
"changelog"
|
||||
"version"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"optionalDependencies": {
|
||||
"babel": "^5.5.6"
|
||||
},
|
||||
"release": {
|
||||
"verification": "cracks"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/boennemann/semantic-release.git"
|
||||
@ -60,11 +66,8 @@
|
||||
"scripts": {
|
||||
"postpublish": "./bin/semantic-release.js post",
|
||||
"prepublish": "./bin/semantic-release.js pre",
|
||||
"test:style": "standard",
|
||||
"test": "./bin/test",
|
||||
"test:integration": "node tests | tap-spec",
|
||||
"test": "./bin/test"
|
||||
},
|
||||
"release": {
|
||||
"verification": "cracks"
|
||||
"test:style": "standard"
|
||||
}
|
||||
}
|
||||
|
69
src/main.js
Normal file
69
src/main.js
Normal file
@ -0,0 +1,69 @@
|
||||
'use strict'
|
||||
|
||||
var abbrev = require('abbrev')
|
||||
|
||||
var efh = require('../lib/error').standard
|
||||
|
||||
exports.pre = function (argv, npmArgv, plugins) {
|
||||
// see src/restart.js
|
||||
if (npmArgv['semantic-release-rerun']) {
|
||||
if (!/semantically-released/.test(process.env.npm_package_version)) process.exit(0)
|
||||
|
||||
console.log('There is something wrong with your setup, as a placeholder version is about to be released.')
|
||||
console.log('Please verify that your setup is correct.')
|
||||
console.log('If you think this is a problem with semantic-release please open an issue.')
|
||||
process.exit(1)
|
||||
}
|
||||
// the `prepublish` hook is also executed when the package is installed
|
||||
// in this case we abort the command and do nothing.
|
||||
if (
|
||||
isAbbrev(npmArgv, 'install') ||
|
||||
isAbbrev(npmArgv, 'link') ||
|
||||
isAbbrev(npmArgv, 'pack')
|
||||
) process.exit(0)
|
||||
|
||||
if (argv.debug) console.log('This is a dry run')
|
||||
|
||||
console.log('Determining new version')
|
||||
|
||||
var publish = false
|
||||
if (isAbbrev(npmArgv, 'publish')) publish = true
|
||||
|
||||
// require a correct setup during publish
|
||||
if (publish && !argv.debug && !require('./verify')(argv)) process.exit(1)
|
||||
|
||||
require('./pre')(argv, plugins, efh(function (result) {
|
||||
if (!result) {
|
||||
console.log('Nothing changed. Not publishing.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('Publishing v' + result)
|
||||
if (!publish) process.exit(0)
|
||||
|
||||
if (argv.debug) process.exit(1)
|
||||
|
||||
require('./restart')(efh(function () {
|
||||
process.exit(1)
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
exports.post = function (argv, npmArgv, plugins) {
|
||||
require('./post')(argv, plugins, efh(function () {
|
||||
// see src/restart.js
|
||||
if (npmArgv['semantic-release-rerun']) {
|
||||
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
exports.setup = function () {
|
||||
require('./setup')()
|
||||
console.log('"package.json" is set up properly. Now configure your CI server.')
|
||||
console.log('https://github.com/boennemann/semantic-release#ci-server')
|
||||
}
|
||||
|
||||
function isAbbrev (argv, command) {
|
||||
return argv._.some(Object.prototype.hasOwnProperty.bind(abbrev(command)))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user