Skip to content

Commit

Permalink
feat: allow package-json.lock and yarn.lock to be uppdated simultaneo…
Browse files Browse the repository at this point in the history
…usly, 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
  • Loading branch information
timbru31 authored and ethanrubio committed Aug 8, 2017
1 parent 8b34918 commit ae87c20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/update-lockfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion update.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ module.exports = function update () {
}

updateLockfile(dependency, {
yarn: !!yarnLock
yarn: !!yarnLock,
npm: !!packageLock
})

console.log('Lockfile updated')
Expand Down

0 comments on commit ae87c20

Please sign in to comment.