Last active
September 6, 2018 10:03
-
-
Save lucaronca/6b38faddafdb2b56f5ff1a2a97db5d92 to your computer and use it in GitHub Desktop.
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
// Example: node --experimental-modules update_dep.mjs <package_dir_path> | |
import fs from 'fs'; | |
import path from 'path'; | |
const packageJsonPath = path.join(process.argv[2], './package.json'); | |
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | |
const packageNames = Object.keys(packageJson.dependencies).filter(name => name.startsWith('@adespresso/')); | |
packageNames.forEach((name) => { | |
const depPackagePath = path.join('./packages/global', name.replace('@adespresso/', ''), './package.json'); | |
const { version } = JSON.parse(fs.readFileSync(depPackagePath, 'utf8')); | |
packageJson.dependencies[name] = `^${version}`; | |
}); | |
fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 4)}\n`, 'utf8', () => console.log('Done')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment