diff --git a/lib/lifecycles/bump.js b/lib/lifecycles/bump.js index 2508b69a8..47ad11fd6 100644 --- a/lib/lifecycles/bump.js +++ b/lib/lifecycles/bump.js @@ -135,6 +135,7 @@ function bumpVersion (releaseAs, callback) { */ function updateConfigs (args, newVersion) { 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) { diff --git a/test.js b/test.js index d5fc9bbbe..001c858d0 100644 --- a/test.js +++ b/test.js @@ -59,6 +59,12 @@ function writeNpmShrinkwrapJson (version, option) { fs.writeFileSync('npm-shrinkwrap.json', JSON.stringify(shrinkwrap), 'utf-8') } +function writePackageLockJson (version, option) { + option = option || {} + var pkgLock = Object.assign(option, { version: version }) + fs.writeFileSync('package-lock.json', JSON.stringify(pkgLock), 'utf-8') +} + function writeGitPreCommitHook () { fs.writeFileSync('.git/hooks/pre-commit', '#!/bin/sh\necho "precommit ran"\nexit 1', 'utf-8') fs.chmodSync('.git/hooks/pre-commit', '755') @@ -676,6 +682,24 @@ describe('standard-version', function () { }) }) + describe('package-lock.json support', function () { + beforeEach(function () { + writePackageLockJson('1.0.0') + }) + + it('bumps version # in package-lock.json', function (done) { + 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}) + .then(() => { + JSON.parse(fs.readFileSync('package-lock.json', 'utf-8')).version.should.equal('1.1.0') + getPackageVersion().should.equal('1.1.0') + return done() + }) + }) + }) + describe('dry-run', function () { it('skips all non-idempotent steps', function (done) { commit('feat: first commit')