Skip to content

Commit 7ed4401

Browse files
committed
Modify Client to extend Console
1 parent 808cc84 commit 7ed4401

4 files changed

Lines changed: 11 additions & 22 deletions

File tree

.changeset/wise-plants-open.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"clide-js": patch
3+
---
4+
5+
Modified `Client` to extend `Console` from node.

examples/typescript/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"clide-plugin-command-menu": "0.3.0-next.2"
2020
},
2121
"devDependencies": {
22-
"@tsconfig/node-lts": "^22.0.1",
2322
"tsx": "^4.19.4",
2423
"typescript": "^5.8.3"
2524
}

packages/clide-js/src/core/client.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Console } from 'node:console';
2+
import process from 'node:process';
13
import prompts, { type PromptObject, type PromptType } from 'prompts';
24
import { ClideError, type ClideErrorOptions } from 'src/core/errors';
35
import type { KeyMap, Replace } from 'src/utils/types';
@@ -75,21 +77,17 @@ export type PromptParams<T extends PromptType = PromptType> = Replace<
7577
* [prompts](https://github.com/terkelg/prompts).
7678
* @group Client
7779
*/
78-
export class Client {
79-
/**
80-
* Log a message to stdout.
81-
* @param message - Any number of arguments to log.
82-
*/
83-
log(...message: unknown[]) {
84-
console.log(...message);
80+
export class Client extends Console {
81+
constructor({ stdout = process.stdout, stderr = process.stderr } = {}) {
82+
super({ stdout, stderr });
8583
}
8684

8785
/**
8886
* Log an error message to stderr.
8987
* @param error - The error to log.
9088
* @returns The error wrapped in a {@linkcode ClientError}.
9189
*/
92-
error(error: unknown) {
90+
override error(error: unknown) {
9391
const clientError = new ClientError(error);
9492
console.error(
9593
`\n${
@@ -101,14 +99,6 @@ export class Client {
10199
return clientError;
102100
}
103101

104-
/**
105-
* Log a warning message to stdout.
106-
* @param warning - Any number of arguments to log.
107-
*/
108-
warn(...warning: any) {
109-
console.warn(...warning);
110-
}
111-
112102
/**
113103
* Prompt the user for input.
114104
* @param prompt - The prompt options.

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,6 @@
666666
resolved "https://registry.yarnpkg.com/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz#a90ab31d0cc1dfb54c66a69e515bf624fa7b2224"
667667
integrity sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==
668668

669-
"@tsconfig/node-lts@^22.0.1":
670-
version "22.0.1"
671-
resolved "https://registry.yarnpkg.com/@tsconfig/node-lts/-/node-lts-22.0.1.tgz#dd9809fe37ac966d73a4ca468210a0c6cb09aa97"
672-
integrity sha512-BwlbLiYurZKrj+Pa6etSE1jXmr3VEDdgJto1jEYKcpBVwZZSWVkCPyFEFYbHdIOaFMlSTtV206DYPlT109aqug==
673-
674669
"@types/estree@1.0.6":
675670
version "1.0.6"
676671
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"

0 commit comments

Comments
 (0)