Skip to content

Commit

Permalink
feat: add support for package-lock.json (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
noreiller authored and stevemao committed Jun 6, 2017
1 parent 4b6d6db commit bc0fc53
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/lifecycles/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 24 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit bc0fc53

Please sign in to comment.