Skip to content

Commit ad031b1

Browse files
author
Amelia Wattenbeger
committed
get git status output
1 parent b9edc57 commit ad031b1

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15078,7 +15078,7 @@ var main = async () => {
1507815078
const outputFile = core.getInput("output_file") || "./diagram.svg";
1507915079
await import_fs2.default.writeFileSync(outputFile, componentCodeString);
1508015080
await (0, import_exec.exec)("git", ["add", outputFile]);
15081-
const diff = await (0, import_exec.exec)("git", ["status", "--porcelain", outputFile]);
15081+
const diff = await execWithOutput("git", ["status", "--porcelain", outputFile]);
1508215082
core.info(`diff: ${diff}`);
1508315083
if (!diff) {
1508415084
core.info("[INFO] No changes to the repo detected, exiting");
@@ -15089,6 +15089,26 @@ var main = async () => {
1508915089
console.log("All set!");
1509015090
};
1509115091
main();
15092+
function execWithOutput(command, args) {
15093+
return new Promise((resolve, reject) => {
15094+
try {
15095+
(0, import_exec.exec)(command, args, {
15096+
listeners: {
15097+
stdout: function(res) {
15098+
core.info(res.toString());
15099+
resolve(res.toString());
15100+
},
15101+
stderr: function(res) {
15102+
core.info(res.toString());
15103+
reject(res.toString());
15104+
}
15105+
}
15106+
});
15107+
} catch (e) {
15108+
reject(e);
15109+
}
15110+
});
15111+
}
1509215112
/*
1509315113
object-assign
1509415114
(c) Sindre Sorhus

src/index.jsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const main = async () => {
3030
await fs.writeFileSync(outputFile, componentCodeString)
3131

3232
await exec('git', ['add', outputFile])
33-
const diff = await exec('git', ['status', '--porcelain', outputFile])
33+
const diff = await execWithOutput('git', ['status', '--porcelain', outputFile])
3434
core.info(`diff: ${diff}`)
3535
if (!diff) {
3636
core.info('[INFO] No changes to the repo detected, exiting')
@@ -43,4 +43,26 @@ const main = async () => {
4343
console.log("All set!")
4444
}
4545

46-
main()
46+
main()
47+
48+
function execWithOutput(command, args) {
49+
return new Promise((resolve, reject) => {
50+
try {
51+
exec(command, args, {
52+
listeners: {
53+
stdout: function (res) {
54+
core.info(res.toString())
55+
resolve(res.toString())
56+
},
57+
stderr: function (res) {
58+
core.info(res.toString())
59+
reject(res.toString())
60+
}
61+
}
62+
})
63+
} catch (e) {
64+
reject(e)
65+
}
66+
})
67+
}
68+

0 commit comments

Comments
 (0)