Last active
November 22, 2018 15:45
-
-
Save nash403/f5780e6429a9993189525023f5de1de8 to your computer and use it in GitHub Desktop.
Node/Npm script to force update project dependencies (command: npm run update:packages)
This file contains hidden or 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
“scripts”: { | |
“update:packages”: “node wipe-dependencies.js && | |
rm -rf node_modules && npm update --save-dev | |
&& npm update --save” | |
}, |
This file contains hidden or 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
var fs = require('fs'), | |
wipeDependencies = function() { | |
var file = fs.readFileSync('package.json'), | |
content = JSON.parse(file); | |
for (var devDep in content.devDependencies) { | |
content.devDependencies[devDep] = '*'; | |
} | |
for (var dep in content.dependencies) { | |
content.dependencies[dep] = '*'; | |
} | |
fs.writeFileSync('package.json', JSON.stringify(content,null,2)); | |
}; | |
if (require.main === module) { | |
wipeDependencies(); | |
} else { | |
module.exports = wipeDependencies; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment