mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const { execSync } = require('child_process');
|
|
const { writeFileSync, unlinkSync } = require("fs");
|
|
const { resolve } = require("path");
|
|
|
|
exports.gitBranch = execSync("git branch").toString()
|
|
.split("\n")
|
|
.filter(f => f.trim().startsWith("*"))[0]
|
|
.replace("*", "").trim();
|
|
|
|
exports.createPR = (postQuery) => {
|
|
if (!process.env.GIT_TOKEN) {
|
|
console.error("Missing env variable GIT_TOKEN");
|
|
process.exit(1);
|
|
}
|
|
const releaseDataJsonPath = resolve(process.cwd(), "git-helper.json");
|
|
writeFileSync(releaseDataJsonPath, JSON.stringify(postQuery));
|
|
const result = execSync(` curl -d "@${releaseDataJsonPath}" -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${process.env.GIT_TOKEN}" `);
|
|
console.log(result.toString());
|
|
unlinkSync(releaseDataJsonPath);
|
|
|
|
const requesResultJson = JSON.parse(result);
|
|
execSync(`open ${requesResultJson.html_url}`);
|
|
|
|
return requesResultJson;
|
|
}
|
|
|
|
exports.argsParser = () => {
|
|
args = {};
|
|
process.argv
|
|
.filter(a => a.startsWith("--"))
|
|
.map(el => {
|
|
el = el.split("=");
|
|
const prop = el[0].replace("--", "").replace("-", "").trim();
|
|
const value = el[1].trim();
|
|
args[prop] = value;
|
|
});
|
|
|
|
return args;
|
|
} |