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
33 lines (30 loc) · 1.01 KB
/
Copy pathstdio-helpers.ts
File metadata and controls
33 lines (30 loc) · 1.01 KB
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
26
27
28
29
30
31
32
33
/**
* Writes a message to stdout exactly as provided.
* Use for terminal control sequences or output that manages its own spacing.
*/
export const writeStdout = (message: string): void => {
process.stdout.write(message);
};
/**
* 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();
};