Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for package-lock.json #190

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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