Archived
1
0

Exit when pipe closes

This allows piping to things like `head` without SIGPIPE errors.
This commit is contained in:
Asher 2019-08-12 15:30:07 -05:00
parent c11d5fe9e6
commit 2470081789
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -229,6 +229,12 @@ const main = async(): Promise<boolean | void | void[]> => {
return startCli() || new WrapperProcess().start(); return startCli() || new WrapperProcess().start();
}; };
// It's possible that the pipe has closed (for example if you run code-server
// --version | head -1). Assume that means we're done.
if (!process.stdout.isTTY) {
process.stdout.on("error", () => process.exit());
}
main().catch((error) => { main().catch((error) => {
logger.error(error.message); logger.error(error.message);
process.exit(typeof error.code === "number" ? error.code : 1); process.exit(typeof error.code === "number" ? error.code : 1);