Skip to content

Instantly share code, notes, and snippets.

@lucaronca
Last active September 6, 2018 10:03
Show Gist options
  • Save lucaronca/6b38faddafdb2b56f5ff1a2a97db5d92 to your computer and use it in GitHub Desktop.
Save lucaronca/6b38faddafdb2b56f5ff1a2a97db5d92 to your computer and use it in GitHub Desktop.
// 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