Skip to content

Instantly share code, notes, and snippets.

@dragonman225
Last active January 7, 2020 15:33
Show Gist options
  • Save dragonman225/a83be3582b2ee2e4aff3e20b52700e3d to your computer and use it in GitHub Desktop.
Save dragonman225/a83be3582b2ee2e4aff3e20b52700e3d to your computer and use it in GitHub Desktop.
Upgrade dependencies to the latest with yarn.
/**
* Upgrade dependencies to the latest with pnpm.
*/
const { spawn } = require('child_process')
const manifest = require('../package.json')
const devDeps = Object.keys(manifest.devDependencies
? manifest.devDependencies : [])
const deps = Object.keys(manifest.dependencies
? manifest.dependencies : [])
const devDepsLatest = devDeps.map(d => `${d}@latest`)
const depsLatest = deps.map(d => `${d}@latest`)
const bin = 'yarn'
let args = ['upgrade']
args = args.concat(devDepsLatest)
args = args.concat(depsLatest)
const upgrade = spawn(bin, args)
upgrade.stdout.on('data', (data) => {
console.log(data.toString())
})
upgrade.stderr.on('data', (data) => {
console.error(`stderr: ${data.toString()}`)
})
upgrade.on('close', (code) => {
console.log(`child process exited with code ${code}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment