Created
October 9, 2020 17:19
-
-
Save josh-hemphill/b9d5bd124be3f6b8a60829771593997a to your computer and use it in GitHub Desktop.
npmUpgrade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
const {execSync} = require('child_process'); | |
let result = {}; | |
try { | |
result = execSync(`npm outdated --json --long`); | |
} catch (error) { | |
const {stdout, stderr} = error; | |
result = {stdout, stderr}; | |
} | |
const data = JSON.parse(result.stdout.toString()); | |
const vouln = {}; | |
let devs = 'npm i -D'; | |
let deps = 'npm i'; | |
for (let i in data) { | |
let temp = ` ${i}@^${data[i].latest}`; | |
if (data[i].type === 'devDependencies') { | |
devs += temp; | |
} else { | |
deps += temp; | |
} | |
} | |
console.log(devs); | |
console.log(deps); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment