Skip to content

Commit 2a5c355

Browse files
committed
chore: use ux.stdout from core
1 parent 18dcba8 commit 2a5c355

File tree

4 files changed

+10
-40
lines changed

4 files changed

+10
-40
lines changed

src/ux/table.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import ansis from 'ansis';
99
import { orderBy } from 'natural-orderby';
1010
import sliceAnsi from 'slice-ansi';
1111
import sw from 'string-width';
12-
13-
import write from './write.js';
12+
import { ux } from '@oclif/core';
1413

1514
function sumBy<T>(arr: T[], fn: (i: T) => number): number {
1615
return arr.reduce((sum, i) => sum + fn(i), 0);
@@ -74,7 +73,7 @@ class Table<T extends Record<string, unknown>> {
7473
filter,
7574
'no-header': options['no-header'] ?? false,
7675
'no-truncate': options['no-truncate'] ?? false,
77-
printLine: printLine ?? ((s: string): void => write.stdout(s)),
76+
printLine: printLine ?? ((s: string): void => ux.stdout(s)),
7877
rowStart: ' ',
7978
sort,
8079
title,

src/ux/ux.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { UxBase } from './base.js';
1313
import { Spinner } from './spinner.js';
1414
import { table, Columns as TableColumns, Options as TableOptions } from './table.js';
1515
import styledObject from './styledObject.js';
16-
import write from './write.js';
1716

1817
/**
1918
* UX methods for plugins. Automatically suppress console output if outputEnabled is set to false.
@@ -48,7 +47,7 @@ export class Ux extends UxBase {
4847
* @param args Args to be used for formatting.
4948
*/
5049
public log(message?: string, ...args: string[]): void {
51-
this.maybeNoop(() => write.stdout(message, ...args));
50+
this.maybeNoop(() => ux.stdout(message, ...args));
5251
}
5352

5453
/**
@@ -58,7 +57,7 @@ export class Ux extends UxBase {
5857
* @param args Args to be used for formatting.
5958
*/
6059
public logToStderr(message?: string, ...args: string[]): void {
61-
this.maybeNoop(() => write.stderr(message, ...args));
60+
this.maybeNoop(() => ux.stderr(message, ...args));
6261
}
6362

6463
/**
@@ -89,7 +88,7 @@ export class Ux extends UxBase {
8988
* @param params
9089
*/
9190
public url(text: string, uri: string, params = {}): void {
92-
this.maybeNoop(() => write.stdout(terminalLink(text, uri, { fallback: () => uri, ...params })));
91+
this.maybeNoop(() => ux.stdout(terminalLink(text, uri, { fallback: () => uri, ...params })));
9392
}
9493

9594
/**
@@ -110,7 +109,7 @@ export class Ux extends UxBase {
110109

111110
const mergedTheme = { ...defaultTheme, ...theme };
112111

113-
this.maybeNoop(() => write.stdout(ux.colorizeJson(obj, { theme: mergedTheme })));
112+
this.maybeNoop(() => ux.stdout(ux.colorizeJson(obj, { theme: mergedTheme })));
114113
}
115114

116115
/**
@@ -120,7 +119,7 @@ export class Ux extends UxBase {
120119
* @param keys Keys of object to display
121120
*/
122121
public styledObject(obj: AnyJson, keys?: string[]): void {
123-
this.maybeNoop(() => write.stdout(styledObject(obj, keys)));
122+
this.maybeNoop(() => ux.stdout(styledObject(obj, keys)));
124123
}
125124

126125
/**
@@ -129,7 +128,7 @@ export class Ux extends UxBase {
129128
* @param text header to display
130129
*/
131130
public styledHeader(text: string): void {
132-
this.maybeNoop(() => write.stdout(ansis.dim('=== ') + ansis.bold(text) + '\n'));
131+
this.maybeNoop(() => ux.stdout(ansis.dim('=== ') + ansis.bold(text) + '\n'));
133132
}
134133
}
135134

src/ux/write.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/unit/ux/ux.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
import { expect } from 'chai';
99
import sinon from 'sinon';
10+
import { ux as coreUx } from '@oclif/core';
1011
import { Ux } from '../../../src/ux/ux.js';
11-
import write from '../../../src/ux/write.js';
1212

1313
describe('Ux', () => {
1414
let sandbox: sinon.SinonSandbox;
1515
let stdoutStub: sinon.SinonStub;
1616

1717
beforeEach(() => {
1818
sandbox = sinon.createSandbox();
19-
stdoutStub = sandbox.stub(write, 'stdout').callsFake(() => {});
19+
stdoutStub = sandbox.stub(coreUx, 'stdout').callsFake(() => {});
2020
});
2121

2222
afterEach(() => {

0 commit comments

Comments
 (0)