diff --git a/.gitignore b/.gitignore index 7e95d3c2b..7d21798c9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ npm-debug.log # coverage coverage +package-lock.json \ No newline at end of file diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index 47ad11fd6..4ab091cce 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -1,8 +1,11 @@ +'use strict' + const chalk = require('chalk') const checkpoint = require('../checkpoint') const conventionalRecommendedBump = require('conventional-recommended-bump') const figures = require('figures') const fs = require('fs') +const DotGitignore = require('dotgitignore') const path = require('path') const runLifecycleScript = require('../run-lifecycle-script') const semver = require('semver') @@ -134,12 +137,14 @@ function bumpVersion (releaseAs, callback) { * @return {string} */ function updateConfigs (args, newVersion) { + const dotgit = DotGitignore() configsToUpdate[path.resolve(process.cwd(), './package.json')] = false configsToUpdate[path.resolve(process.cwd(), './package-lock.json')] = false configsToUpdate[path.resolve(process.cwd(), './npm-shrinkwrap.json')] = false configsToUpdate[path.resolve(process.cwd(), './bower.json')] = false Object.keys(configsToUpdate).forEach(function (configPath) { try { + if (dotgit.ignore(configPath)) return var stat = fs.lstatSync(configPath) if (stat.isFile()) { var config = require(configPath) diff --git a/package.json b/package.json index eecc1d30c..128ac8932 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "chalk": "^1.1.3", "conventional-changelog": "^1.1.0", "conventional-recommended-bump": "^1.0.0", + "dotgitignore": "^1.0.3", "figures": "^1.5.0", "fs-access": "^1.0.0", "semver": "^5.1.0", diff --git a/test.js b/test.js index b18cf7150..a2e045017 100644 --- a/test.js +++ b/test.js @@ -590,6 +590,32 @@ describe('cli', function () { var pkgJson = fs.readFileSync('package.json', 'utf-8') pkgJson.should.equal(['{', ' "version": "1.1.0"', '}', ''].join('\n')) }) + + it('exits with error code if "scripts" is not an object', () => { + writePackageJson('1.0.0', { + 'standard-version': { + scripts: 'echo hello' + } + }) + + commit('feat: first commit') + var result = execCli() + result.code.should.equal(1) + result.stderr.should.match(/scripts must be an object/) + }) + + it('exits with error code if "skip" is not an object', () => { + writePackageJson('1.0.0', { + 'standard-version': { + skip: true + } + }) + + commit('feat: first commit') + var result = execCli() + result.code.should.equal(1) + result.stderr.should.match(/skip must be an object/) + }) }) describe('standard-version', function () { @@ -672,15 +698,14 @@ describe('standard-version', function () { writeBowerJson('1.0.0') }) - it('bumps version # in bower.json', function (done) { + it('bumps version # in bower.json', 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}) + 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') - return done() }) }) }) @@ -706,17 +731,17 @@ describe('standard-version', function () { describe('package-lock.json support', function () { beforeEach(function () { writePackageLockJson('1.0.0') + fs.writeFileSync('.gitignore', '', 'utf-8') }) - it('bumps version # in package-lock.json', function (done) { + it('bumps version # in package-lock.json', 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}) + 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') - return done() }) }) }) @@ -765,4 +790,23 @@ describe('standard-version', function () { }) }) }) + + describe('.gitignore', () => { + beforeEach(function () { + writeBowerJson('1.0.0') + }) + + it('does not update files present in .gitignore', () => { + fs.writeFileSync('.gitignore', 'bower.json', 'utf-8') + + 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}) + .then(() => { + JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.0.0') + getPackageVersion().should.equal('1.1.0') + }) + }) + }) })