release 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env node
  2. var fs = require("fs"), child = require("child_process");
  3. var number, bumpOnly;
  4. for (var i = 2; i < process.argv.length; i++) {
  5. if (process.argv[i] == "-bump") bumpOnly = true;
  6. else if (/^\d+\.\d+\.\d+$/.test(process.argv[i])) number = process.argv[i];
  7. else { console.log("Bogus command line arg: " + process.argv[i]); process.exit(1); }
  8. }
  9. if (!number) { console.log("Must give a version"); process.exit(1); }
  10. function rewrite(file, f) {
  11. fs.writeFileSync(file, f(fs.readFileSync(file, "utf8")), "utf8");
  12. }
  13. rewrite("src/edit/main.js", function(lib) {
  14. return lib.replace(/CodeMirror\.version = "\d+\.\d+\.\d+"/,
  15. "CodeMirror.version = \"" + number + "\"");
  16. });
  17. function rewriteJSON(pack) {
  18. return pack.replace(/"version":\s*"\d+\.\d+\.\d+"/, "\"version\": \"" + number + "\"");
  19. }
  20. rewrite("package.json", rewriteJSON);
  21. rewrite("doc/manual.html", function(manual) {
  22. return manual.replace(/>version \d+\.\d+\.\d+<\/span>/, ">version " + number + "</span>");
  23. });
  24. if (bumpOnly) process.exit(0);
  25. child.exec("bash bin/authors.sh", function(){});
  26. rewrite("index.html", function(index) {
  27. return index.replace(/\.zip">\d+\.\d+\.\d+<\/a>/,
  28. ".zip\">" + number + "</a>");
  29. });