Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ if (values.format === 'table') {
}

// --- Post GitHub suggestion comments (async, fail-open) ---
// IMPORTANT: process.exit must be deferred until after async suggestion posting
// completes. Calling process.exit() synchronously would terminate the Node.js
// process before unresolved HTTP requests to the GitHub API resolve, causing
// suggestions to be silently dropped on policy violation builds.
if (values['post-suggestions']) {
const token = values['github-token'];
const repo = values['repo'];
Expand All @@ -151,6 +155,7 @@ if (values['post-suggestions']) {
process.stderr.write(
'[WARN] --post-suggestions requires --github-token, --repo, --pr-number, and --commit-sha. Skipping.\n'
);
process.exit(policyExitCode);
} else {
postSuggestions(result, {
token,
Expand All @@ -172,8 +177,11 @@ if (values['post-suggestions']) {
process.stderr.write(
`[WARN] GreenOps suggestion engine error: ${err instanceof Error ? err.message : String(err)}. Continuing.\n`
);
}).finally(() => {
// Exit only after suggestions have been posted (or failed gracefully)
process.exit(policyExitCode);
});
}
} else {
process.exit(policyExitCode);
}

process.exit(policyExitCode);
8 changes: 6 additions & 2 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ var factors_default = {
// package.json
var package_default = {
name: "greenops-cli",
version: "0.5.3",
version: "0.5.4",
description: "Carbon footprint linting for Terraform plans \u2014 AWS, Azure, and GCP. Analyses infrastructure changes for Scope 2, Scope 3, and water impact. Posts recommendations directly on GitHub PRs.",
main: "dist/index.cjs",
bin: {
Expand Down Expand Up @@ -3170,6 +3170,7 @@ if (values["post-suggestions"]) {
process.stderr.write(
"[WARN] --post-suggestions requires --github-token, --repo, --pr-number, and --commit-sha. Skipping.\n"
);
process.exit(policyExitCode);
} else {
postSuggestions(result, {
token,
Expand All @@ -3193,7 +3194,10 @@ if (values["post-suggestions"]) {
`[WARN] GreenOps suggestion engine error: ${err instanceof Error ? err.message : String(err)}. Continuing.
`
);
}).finally(() => {
process.exit(policyExitCode);
});
}
} else {
process.exit(policyExitCode);
}
process.exit(policyExitCode);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "greenops-cli",
"version": "0.5.3",
"version": "0.5.4",
"description": "Carbon footprint linting for Terraform plans \u2014 AWS, Azure, and GCP. Analyses infrastructure changes for Scope 2, Scope 3, and water impact. Posts recommendations directly on GitHub PRs.",
"main": "dist/index.cjs",
"bin": {
Expand Down
Loading