forked from lessweb/deepcode-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdio-helpers.ts
More file actions
25 lines (23 loc) · 808 Bytes
/
Copy pathstdio-helpers.ts
File metadata and controls
25 lines (23 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* Writes a message to stdout with a trailing newline.
* Use for normal command output that the user expects to see.
* Avoids double newlines if the message already ends with one.
*/
export const writeStdoutLine = (message: string): void => {
process.stdout.write(message.endsWith("\n") ? message : `${message}\n`);
};
/**
* Writes a message to stderr with a trailing newline.
* Use for error messages in CLI commands.
* Avoids double newlines if the message already ends with one.
*/
export const writeStderrLine = (message: string): void => {
process.stderr.write(message.endsWith("\n") ? message : `${message}\n`);
};
/**
* Clears the terminal screen.
* Use instead of console.clear() to satisfy no-console lint rules.
*/
export const clearScreen = (): void => {
console.clear();
};