land 851 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env node
  2. "use strict";
  3. var url = "https://github.com/jshint/jshint/pull/" + process.argv[2] + ".patch";
  4. var https = require("https");
  5. var shjs = require("shelljs");
  6. var opts = require("url").parse(url);
  7. var msg = process.argv[3];
  8. opts.rejectUnauthorized = false;
  9. opts.agent = new https.Agent(opts);
  10. https.get(opts, succ).on("error", err);
  11. function succ(res) {
  12. if (res.statusCode !== 200)
  13. return void console.log("error:", res.statusCode);
  14. var data = "";
  15. res.on("data", function (chunk) {
  16. data += chunk.toString();
  17. });
  18. res.on("end", function () {
  19. data = data.split("\n");
  20. data = data[1].replace(/^From\:\s/, "");
  21. data = data.replace(/"/g, "");
  22. shjs.exec("git commit -s --author=\"" + data + "\" --message=\"" + msg + "\"");
  23. });
  24. }
  25. function err(res) {
  26. console.log("error:", res.message);
  27. }