Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
version: Fixed lockfiles not being added to the commit (#17742)
Browse files Browse the repository at this point in the history
* Sequential promises instead of concurrent

* Fixed style errors

* Removed the promise constructor

PR-URL: #17742
Credit: @markpeterfejes
Reviewed-By: @zkat
  • Loading branch information
markpeterfejes authored and zkat committed Jul 13, 2017
1 parent f153b5b commit 542f756
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,30 @@ function _commit (version, localData, cb) {
const options = { env: process.env }
const message = npm.config.get('message').replace(/%s/g, version)
const sign = npm.config.get('sign-git-tag')
const flag = sign ? '-sm' : '-am'
BB.join(
addLocalFile('package.json', options, false),
localData.hasShrinkwrap &&
addLocalFile('npm-shrinkwrap.json', options, true),
localData.hasPackageLock &&
addLocalFile('package-lock.json', options, true)
).then(() => {
const flagForTag = sign ? '-sm' : '-am'

stagePackageFiles(localData, options).then(() => {
return git.exec([ 'commit', '-m', message ], options)
}).then(() => {
if (!localData.existingTag) {
return git.exec([
'tag', npm.config.get('tag-version-prefix') + version,
flag, message
flagForTag, message
], options)
}
}).nodeify(cb)
}

function stagePackageFiles (localData, options) {
return addLocalFile('package.json', options, false).then(() => {
if (localData.hasShrinkwrap) {
return addLocalFile('npm-shrinkwrap.json', options, false)
} else if (localData.hasPackageLock) {
return addLocalFile('package-lock.json', options, false)
}
})
}

function addLocalFile (file, options, ignoreFailure) {
const p = git.exec(['add', path.join(npm.localPrefix, file)], options)
return ignoreFailure
Expand Down

0 comments on commit 542f756

Please sign in to comment.