synchronize-versions.js 543 B

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