From ae87c20bf26ae8237c3c453c2f2cc05978e1879e Mon Sep 17 00:00:00 2001 From: Tim Brust Date: Tue, 8 Aug 2017 19:07:26 +0200 Subject: [PATCH] feat: allow package-json.lock and yarn.lock to be uppdated simultaneously, fixes #39 (#42) * feat: allow package-json.lock and yarn.lock to be uppdated simultaneously, fixes #39 * fix: correctly set args for yarn and npm * fix: revert package-lock.json --- lib/update-lockfile.js | 18 +++++++++--------- update.js | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/update-lockfile.js b/lib/update-lockfile.js index 802a4daa..1f086874 100644 --- a/lib/update-lockfile.js +++ b/lib/update-lockfile.js @@ -28,17 +28,17 @@ module.exports = function updateLockfile (dependency, options) { exec('git revert -n HEAD') exec('git reset HEAD') - // manually reinstall the package so the lockfile is updated - const flag = options.yarn ? yarnFlags[dependency.type] : flags[dependency.type] - const prefix = options.yarn - ? setPrefixYarn(dependency.prefix) - : `--save-prefix="${dependency.prefix}"` - - const args = `${flag} ${prefix} ${dependency.name}@${dependency.version}` - if (options.yarn) { + const flag = yarnFlags[dependency.type] + const prefix = setPrefixYarn(dependency.prefix) + const args = `${flag} ${prefix} ${dependency.name}@${dependency.version}` exec(`yarn add ${args}`) - } else { + } + + if (options.npm) { + const flag = flags[dependency.type] + const prefix = `--save-prefix="${dependency.prefix}"` + const args = `${flag} ${prefix} ${dependency.name}@${dependency.version}` var npmBin = 'npm' try { exec('npm5 -v') diff --git a/update.js b/update.js index 4715f793..40da7594 100755 --- a/update.js +++ b/update.js @@ -58,7 +58,8 @@ module.exports = function update () { } updateLockfile(dependency, { - yarn: !!yarnLock + yarn: !!yarnLock, + npm: !!packageLock }) console.log('Lockfile updated')