Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 4d71ec2

Browse files
committed
fix: add ux alias
1 parent d27775f commit 4d71ec2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {ExitError} from './exit'
88
import {IPromptOptions} from './prompt'
99
import * as Table from './styled/table'
1010

11-
export const cli = {
11+
export const ux = {
1212
config,
1313

1414
warn: Errors.warn,
@@ -18,7 +18,7 @@ export const cli = {
1818
get prompt() { return deps.prompt.prompt },
1919
get confirm() { return deps.prompt.confirm },
2020
get action() { return config.action },
21-
styledObject(obj: any, keys?: string[]) { cli.info(deps.styledObject(obj, keys)) },
21+
styledObject(obj: any, keys?: string[]) { ux.info(deps.styledObject(obj, keys)) },
2222
get styledHeader() { return deps.styledHeader },
2323
get styledJSON() { return deps.styledJSON },
2424
get table() { return deps.table },
@@ -72,24 +72,25 @@ export const cli = {
7272
function timeout(p: Promise<any>, ms: number) {
7373
function wait(ms: number, unref: boolean = false) {
7474
return new Promise(resolve => {
75-
let t: any = setTimeout(resolve, ms)
75+
let t: any = setTimeout(() => resolve(), ms)
7676
if (unref) t.unref()
7777
})
7878
}
7979

80-
return Promise.race([p, wait(ms, true).then(() => cli.warn('timed out'))])
80+
return Promise.race([p, wait(ms, true).then(() => ux.warn('timed out'))])
8181
}
8282

8383
async function flush() {
84-
let p = new Promise(resolve => process.stdout.once('drain', resolve))
84+
let p = new Promise(resolve => process.stdout.once('drain', () => resolve()))
8585
process.stdout.write('')
8686
return p
8787
}
8888

8989
await timeout(flush(), 10000)
9090
}
9191
}
92-
export default cli
92+
export default ux
93+
export const cli = ux
9394

9495
export {
9596
config,
@@ -102,7 +103,7 @@ export {
102103

103104
process.once('exit', async () => {
104105
try {
105-
await cli.done()
106+
await ux.done()
106107
} catch (err) {
107108
// tslint:disable no-console
108109
console.error(err)

0 commit comments

Comments
 (0)