Skip to content

Commit

Permalink
inherit stdout and stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Dec 13, 2024
1 parent 28be5d6 commit 071ce78
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function getArguments(): string[] {
* @returns {Promise<void>} A promise that resolves when the command is executed.
*/
async function runScorecard(binary: string): Promise<void> {
// const child = spawn(binary, getArguments(), {
// spawn(binary, getArguments(), {
// env: {
// AZURE_DEVOPS_AUTH_TOKEN:
// process.env["INPUT_REPOTOKEN"] ??
Expand All @@ -184,17 +184,26 @@ async function runScorecard(binary: string): Promise<void> {
// },
// });

const child = spawn(binary, ["--repo", "github.com/ossf/scorecard"], {
env: {
GITHUB_AUTH_TOKEN: process.env["INPUT_REPOTOKEN"],
SCORECARD_EXPERIMENTAL: "true",
},
});
child.stdout.on("data", (data) => {
console.log(data.toString());
});
child.stderr.on("data", (data) => {
console.error(data.toString());
return new Promise((resolve, reject) => {
const child = spawn(binary, ["--repo", "github.com/ossf/scorecard"], {
env: {
GITHUB_AUTH_TOKEN: process.env["INPUT_REPOTOKEN"],
SCORECARD_EXPERIMENTAL: "true",
},
stdio: "inherit",
});

child.on("close", (code) => {
if (code !== 0) {
reject(new Error(`Scorecard process exited with code ${code}`));
} else {
resolve();
}
});

child.on("error", (err) => {
reject(err);
});
});
}

Expand All @@ -214,5 +223,5 @@ async function run(): Promise<void> {
// Run the main function
run().catch((error) => {
console.error(error);
process.exit();
process.exit(1);
});

0 comments on commit 071ce78

Please sign in to comment.