Created
November 26, 2024 09:47
-
-
Save JamieMason/a8023e9cf95858ea0084ed5c48397380 to your computer and use it in GitHub Desktop.
Use same versions as another local package.json
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
const from = require('/Users/foldleft/Dev/foo/bar/package.json'); | |
const to = require('./package.json'); | |
Object.entries(from.dependencies).forEach(([name, version]) => { | |
if (to.dependencies[name]) { | |
to.dependencies[name] = version; | |
} | |
}); | |
Object.entries(from.devDependencies).forEach(([name, version]) => { | |
if (to.devDependencies[name]) { | |
to.devDependencies[name] = version; | |
} | |
}); | |
require('fs').writeFileSync('./package.json', JSON.stringify(to, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment