diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-08 14:32:35 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-08 14:32:35 +0200 |
commit | 68ec88c62096faf5c8538bec4431868919ae9652 (patch) | |
tree | c057a90cb110af2a2343955dfc66dc0978845434 /scripts | |
parent | 47a27fc12d7b91fae9df9ed7bc63ccd645e866eb (diff) | |
download | gitbook-68ec88c62096faf5c8538bec4431868919ae9652.zip gitbook-68ec88c62096faf5c8538bec4431868919ae9652.tar.gz gitbook-68ec88c62096faf5c8538bec4431868919ae9652.tar.bz2 |
Add script to bump version
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bump.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/bump.js b/scripts/bump.js new file mode 100755 index 0000000..4f21a3f --- /dev/null +++ b/scripts/bump.js @@ -0,0 +1,36 @@ +#! /usr/bin/env node + +const fs = require('fs'); +const path = require('path'); + +const lernaConfig = require('../lerna.json'); + +// List all the packages +const PACKAGES_DIR = path.resolve(__dirname, '../packages'); +const packages = fs.readdirSync(PACKAGES_DIR); + +function updateDependencies(dependencies) { + Object.keys(dependencies).map((key) => { + if (!packages.includes(key)) { + return; + } + + dependencies[key] = lernaConfig.version; + }); +} + +packages.forEach((name) => { + // Avoid .DS_Store + if (name[0] === '.') { + return; + } + + const pkgPath = path.resolve(PACKAGES_DIR, name, 'package.json'); + const pkg = require(pkgPath); + + pkg.version = lernaConfig.version; + updateDependencies(pkg.dependencies); + updateDependencies(pkg.devDependencies); + + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 3), 'utf-8'); +}); |