Created
April 27, 2017 19:19
-
-
Save jeremija/c1a284ab42ac80c5aaf62af7b8cd7525 to your computer and use it in GitHub Desktop.
update node deps
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
'use strict'; | |
const pkg = require('./package.json'); | |
const _ = require('underscore'); | |
const fs = require('fs'); | |
const deps = {}; | |
fs.readFileSync('./deps').toString().split('\n').forEach(row => { | |
row = row.split('@'); | |
deps[row[0]] = row[1]; | |
}); | |
const dependencies = _.mapObject(pkg.dependencies, (value, dep) => { | |
if (value.startsWith('git+')) return value; | |
return deps[dep]; | |
}); | |
const devDependencies = _.mapObject(pkg.devDependencies, (value, dep) => { | |
if (dep.startsWith('git+')) return value; | |
return deps[dep]; | |
}); | |
pkg.dependencies = dependencies; | |
pkg.devDependencies = devDependencies; | |
const json = JSON.stringify(pkg, null, ' '); | |
fs.writeFileSync('package2.json', json); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment