daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { readFileSync } = require('fs')
  2.  
  3. const generateNpmInstallScript = (obj, initialScript) => {
  4.   return Object.keys(obj).reduce((script, key) => {
  5.     return script + ' ' + key + '@latest'
  6.   }, initialScript)
  7. }
  8.  
  9. const contents = readFileSync('./package.json', 'utf-8')
  10.  
  11. const {
  12.   dependencies,
  13.   devDependencies
  14. } = JSON.parse(contents)
  15.  
  16. console.log(generateNpmInstallScript(dependencies, 'npm install'))
  17. console.log(generateNpmInstallScript(devDependencies, 'npm install --save-dev'))
RAW Paste Data
Top