Skip to content

Commit

Permalink
fix: bin now enforces Node.js > 4 (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Nov 1, 2018
1 parent 1d46627 commit e1b5780
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node
var standardVersion = require('../index')
var cmdParser = require('../command')

/* istanbul ignore if */
if (process.version.match(/v(\d+)\./)[1] < 4) {
console.error('standard-version: Node v4 or greater is required. `standard-version` did not run.')
if (process.version.match(/v(\d+)\./)[1] < 6) {
console.error('standard-version: Node v6 or greater is required. `standard-version` did not run.')
} else {
const standardVersion = require('../index')
const cmdParser = require('../command')
standardVersion(cmdParser.argv)
.catch(() => {
process.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions lib/lifecycles/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function outputChangelog (args, newVersion) {
}
var content = ''
var context
if (args.dryRun) context = {version: newVersion}
if (args.dryRun) context = { version: newVersion }
var changelogStream = conventionalChangelog({
preset: 'angular',
tagPrefix: args.tagPrefix
}, context, {merges: null})
}, context, { merges: null })
.on('error', function (err) {
return reject(err)
})
Expand Down
2 changes: 1 addition & 1 deletion lib/run-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (args, cmd) {
printError(args, stderr || err.message)
return reject(err)
} else if (stderr) {
printError(args, stderr, {level: 'warn', color: 'yellow'})
printError(args, stderr, { level: 'warn', color: 'yellow' })
}
return resolve(stdout)
})
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@
},
"homepage": "https://github.com/conventional-changelog/standard-version#readme",
"dependencies": {
"chalk": "^1.1.3",
"conventional-changelog": "^1.1.0",
"conventional-recommended-bump": "^1.0.0",
"chalk": "^2.4.1",
"conventional-changelog": "^3.0.5",
"conventional-recommended-bump": "^4.0.4",
"dotgitignore": "^1.0.3",
"figures": "^1.5.0",
"figures": "^2.0.0",
"fs-access": "^1.0.0",
"semver": "^5.1.0",
"yargs": "^8.0.1"
"yargs": "^12.0.2"
},
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^3.0.1",
"mocha": "^5.2.0",
"mock-git": "^1.0.2",
"mock-git": "^1.0.3",
"mockery": "^2.0.0",
"nyc": "^11.0.2",
"shelljs": "^0.7.3",
"standard": "^11.0.1"
"nyc": "^13.1.0",
"shelljs": "^0.7.8",
"standard": "^12.0.1"
}
}
32 changes: 16 additions & 16 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ function execCliAsync (argString) {

function writePackageJson (version, option) {
option = option || {}
var pkg = Object.assign(option, {version: version})
var pkg = Object.assign(option, { version: version })
fs.writeFileSync('package.json', JSON.stringify(pkg), 'utf-8')
delete require.cache[require.resolve(path.join(process.cwd(), 'package.json'))]
}

function writeBowerJson (version, option) {
option = option || {}
var bower = Object.assign(option, {version: version})
var bower = Object.assign(option, { version: version })
fs.writeFileSync('bower.json', JSON.stringify(bower), 'utf-8')
}

function writeManifestJson (version, option) {
option = option || {}
var manifest = Object.assign(option, {version: version})
var manifest = Object.assign(option, { version: version })
fs.writeFileSync('manifest.json', JSON.stringify(manifest), 'utf-8')
}

Expand Down Expand Up @@ -607,7 +607,7 @@ describe('cli', function () {
})

it('does not display `npm publish` if the package is private', function () {
writePackageJson('1.0.0', {private: true})
writePackageJson('1.0.0', { private: true })

var result = execCli()
result.code.should.equal(0)
Expand Down Expand Up @@ -666,7 +666,7 @@ describe('standard-version', function () {

describe('with mocked conventionalRecommendedBump', function () {
beforeEach(function () {
mockery.enable({warnOnUnregistered: false, useCleanCache: true})
mockery.enable({ warnOnUnregistered: false, useCleanCache: true })
mockery.registerMock('conventional-recommended-bump', function (_, cb) {
cb(new Error('bump err'))
})
Expand All @@ -682,7 +682,7 @@ describe('standard-version', function () {
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')

require('./index')({silent: true})
require('./index')({ silent: true })
.catch((err) => {
err.message.should.match(/bump err/)
done()
Expand All @@ -692,9 +692,9 @@ describe('standard-version', function () {

describe('with mocked conventionalChangelog', function () {
beforeEach(function () {
mockery.enable({warnOnUnregistered: false, useCleanCache: true})
mockery.enable({ warnOnUnregistered: false, useCleanCache: true })
mockery.registerMock('conventional-changelog', function () {
var readable = new stream.Readable({objectMode: true})
var readable = new stream.Readable({ objectMode: true })
readable._read = function () {
}
setImmediate(readable.emit.bind(readable), 'error', new Error('changelog err'))
Expand All @@ -712,7 +712,7 @@ describe('standard-version', function () {
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')

require('./index')({silent: true})
require('./index')({ silent: true })
.catch((err) => {
err.message.should.match(/changelog err/)
return done()
Expand All @@ -725,7 +725,7 @@ describe('standard-version', function () {
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')

require('./index')({silent: true})
require('./index')({ silent: true })
.then(() => {
// check last commit message
shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\): 1\.1\.0/)
Expand All @@ -738,7 +738,7 @@ describe('standard-version', function () {
describe('without a package file to bump', function () {
it('should exit with error', function () {
shell.rm('package.json')
return require('./index')({silent: true})
return require('./index')({ silent: true })
.catch((err) => {
err.message.should.equal('no package file found')
})
Expand All @@ -754,7 +754,7 @@ describe('standard-version', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
return require('./index')({silent: true})
return require('./index')({ silent: true })
.then(() => {
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
Expand All @@ -771,7 +771,7 @@ describe('standard-version', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
return require('./index')({silent: true})
return require('./index')({ silent: true })
.then(() => {
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
Expand All @@ -788,7 +788,7 @@ describe('standard-version', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
require('./index')({silent: true})
require('./index')({ silent: true })
.then(() => {
JSON.parse(fs.readFileSync('npm-shrinkwrap.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
Expand All @@ -807,7 +807,7 @@ describe('standard-version', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
return require('./index')({silent: true})
return require('./index')({ silent: true })
.then(() => {
JSON.parse(fs.readFileSync('package-lock.json', 'utf-8')).version.should.equal('1.1.0')
getPackageVersion().should.equal('1.1.0')
Expand Down Expand Up @@ -871,7 +871,7 @@ describe('standard-version', function () {
commit('feat: first commit')
shell.exec('git tag -a v1.0.0 -m "my awesome first release"')
commit('feat: new feature!')
return require('./index')({silent: true})
return require('./index')({ silent: true })
.then(() => {
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.0.0')
getPackageVersion().should.equal('1.1.0')
Expand Down

0 comments on commit e1b5780

Please sign in to comment.