tag.js 967 Bytes
Newer Older
Amanda Chen's avatar
Amanda Chen committed
1
var execSync = require("child_process").execSync;
Amanda Chen's avatar
Amanda Chen committed
2
function execute(cmd) {
Amanda Chen's avatar
Amanda Chen committed
3
  execSync(cmd, function (error, stdout, stderr) {
Amanda Chen's avatar
Amanda Chen committed
4
    if (error) {
5
      console.error("发生错误l", error);
Amanda Chen's avatar
Amanda Chen committed
6
      process.exit(1);
Amanda Chen's avatar
Amanda Chen committed
7
      // throw error;
Amanda Chen's avatar
Amanda Chen committed
8 9 10 11 12 13
    }
  });
}

var arguments = process.argv.splice(2);
let params = {
Amanda Chen's avatar
Amanda Chen committed
14
  tag: null,
Amanda Chen's avatar
Amanda Chen committed
15 16 17 18 19 20 21 22 23 24 25 26
  m: null || "未知",
};
for (let item of arguments) {
  let index = item.indexOf("=");
  let key = item.substring(2, index);
  let value = item.substr(index + 1);
  for (let jtem in params) {
    if (key == jtem) {
      params[jtem] = value;
    }
  }
}
Amanda Chen's avatar
Amanda Chen committed
27 28 29
if (!params.tag) {
  throw "tag params is required!";
}
Amanda Chen's avatar
Amanda Chen committed
30 31 32 33 34 35 36 37

execute("git checkout develop");
execute("git pull");
execute("git checkout master");
execute("git merge --no-ff develop");
execute("git push");
execute(`git tag -a ${params.tag} -m ${params.m}`);
execute(`git push --tags `);
Amanda Chen's avatar
Amanda Chen committed
38
console.log("successfull");
39 40 41
console.log("successfull");
console.log("successfull");
console.log("successfull");