synchronize-versions.js 499 B

12345678910111213141516
  1. #!/usr/bin/env node
  2. // Synchronizes the version in contracts/package.json with the one in package.json.
  3. // This is run automatically when npm version is run.
  4. const fs = require('fs');
  5. const cp = require('child_process');
  6. setVersion('contracts/package.json');
  7. function setVersion (file) {
  8. const json = JSON.parse(fs.readFileSync(file));
  9. json.version = process.env.npm_package_version;
  10. fs.writeFileSync(file, JSON.stringify(json, null, 2) + '\n');
  11. cp.execFileSync('git', ['add', file]);
  12. }