Skip to content

Commit

Permalink
refactor: use basename as key in configsToUpdate and do not fill false
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniGod committed May 5, 2019
1 parent 811bd23 commit b645c16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
9 changes: 3 additions & 6 deletions lib/lifecycles/bump.js
Expand Up @@ -158,10 +158,8 @@ function bumpVersion (releaseAs, args) {
*/
function updateConfigs (args, newVersion) {
const dotgit = DotGitignore()
Bump.pkgFiles.concat(Bump.lockFiles).forEach((filename) => {
configsToUpdate[path.resolve(process.cwd(), filename)] = false
})
Object.keys(configsToUpdate).forEach(function (configPath) {
Bump.pkgFiles.concat(Bump.lockFiles).forEach(function (filename) {
let configPath = path.resolve(process.cwd(), filename)
try {
if (dotgit.ignore(configPath)) return
let stat = fs.lstatSync(configPath)
Expand All @@ -170,13 +168,12 @@ function updateConfigs (args, newVersion) {
let indent = detectIndent(data).indent
let newline = detectNewline(data)
let config = JSON.parse(data)
let filename = path.basename(configPath)
checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion])
config.version = newVersion
writeFile(args, configPath, stringifyPackage(config, indent, newline))
// flag any config files that we modify the version # for
// as having been updated.
configsToUpdate[configPath] = true
configsToUpdate[filename] = true
}
} catch (err) {
if (err.code !== 'ENOENT') console.warn(err.message)
Expand Down
8 changes: 3 additions & 5 deletions lib/lifecycles/commit.js
Expand Up @@ -25,11 +25,9 @@ function execCommit (args, newVersion) {
// commit any of the config files that we've updated
// the version # for.
Object.keys(bump.getUpdatedConfigs()).forEach(function (p) {
if (bump.getUpdatedConfigs()[p]) {
msg += ' and %s'
paths.unshift(path.basename(p))
toAdd += ' ' + path.relative(process.cwd(), p)
}
msg += ' and %s'
paths.unshift(p)
toAdd += ' ' + path.relative(process.cwd(), p)
})

if (args.commitAll) {
Expand Down

0 comments on commit b645c16

Please sign in to comment.