Skip to content

Commit fabacab

Browse files
authoredFeb 15, 2024··
fix truncated JSON output with JSON reporter (#512)
* fix truncated JSON output with JSON reporter * add comment * output newline for JSON reporter
1 parent a7c0a81 commit fabacab

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed
 

‎packages/knip/src/reporters/json.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ export default async ({ report, issues, options }: ReporterOptions) => {
9393
}
9494
}
9595

96-
console.log(
97-
JSON.stringify({
98-
files: Array.from(issues.files).map(filePath => relative(filePath)),
99-
issues: Object.values(json),
100-
})
101-
);
96+
const output = JSON.stringify({
97+
files: Array.from(issues.files).map(filePath => relative(filePath)),
98+
issues: Object.values(json),
99+
});
100+
101+
// See: https://github.com/nodejs/node/issues/6379
102+
// @ts-expect-error _handle is private
103+
process.stdout._handle?.setBlocking?.(true);
104+
process.stdout.write(output + '\n');
102105
};

0 commit comments

Comments
 (0)
Please sign in to comment.