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

Commit

Permalink
fix: add ux alias
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 13, 2018
1 parent d27775f commit 4d71ec2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ExitError} from './exit'
import {IPromptOptions} from './prompt'
import * as Table from './styled/table'

export const cli = {
export const ux = {
config,

warn: Errors.warn,
Expand All @@ -18,7 +18,7 @@ export const cli = {
get prompt() { return deps.prompt.prompt },
get confirm() { return deps.prompt.confirm },
get action() { return config.action },
styledObject(obj: any, keys?: string[]) { cli.info(deps.styledObject(obj, keys)) },
styledObject(obj: any, keys?: string[]) { ux.info(deps.styledObject(obj, keys)) },
get styledHeader() { return deps.styledHeader },
get styledJSON() { return deps.styledJSON },
get table() { return deps.table },
Expand Down Expand Up @@ -72,24 +72,25 @@ export const cli = {
function timeout(p: Promise<any>, ms: number) {
function wait(ms: number, unref: boolean = false) {
return new Promise(resolve => {
let t: any = setTimeout(resolve, ms)
let t: any = setTimeout(() => resolve(), ms)
if (unref) t.unref()
})
}

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

async function flush() {
let p = new Promise(resolve => process.stdout.once('drain', resolve))
let p = new Promise(resolve => process.stdout.once('drain', () => resolve()))
process.stdout.write('')
return p
}

await timeout(flush(), 10000)
}
}
export default cli
export default ux
export const cli = ux

export {
config,
Expand All @@ -102,7 +103,7 @@ export {

process.once('exit', async () => {
try {
await cli.done()
await ux.done()
} catch (err) {
// tslint:disable no-console
console.error(err)
Expand Down

0 comments on commit 4d71ec2

Please sign in to comment.