heroku-cli-command
Advanced tools
Comparing version 1.0.1 to 1.0.2
'use strict' | ||
let supports = require('supports-color') | ||
module.exports = () => { | ||
@@ -8,5 +10,3 @@ return Base => class extends Base { | ||
if (['false', '0'].indexOf((process.env.COLOR || '').toLowerCase()) !== -1) return false | ||
if ((process.env.TERM || '').toLowerCase() === 'dumb') return false | ||
if (this.flags && this.flags['no-color']) return false | ||
return true | ||
return supports | ||
} | ||
@@ -28,5 +28,3 @@ | ||
if (!this.supportsColor) return s | ||
let supports = require('supports-color') | ||
if (!supports) return s | ||
let has256 = supports.has256 || (process.env.TERM || '').indexOf('256') !== -1 | ||
let has256 = this.supportsColor.has256 || (process.env.TERM || '').indexOf('256') !== -1 | ||
return has256 ? '\u001b[38;5;104m' + s + this._color.styles.modifiers.reset.open : this._color.magenta(s) | ||
@@ -33,0 +31,0 @@ } |
@@ -67,4 +67,7 @@ 'use strict' | ||
Command._version = require('../package.json').version | ||
Command.flags = [{name: 'debug', char: 'd', hidden: true}] | ||
Command.flags = [ | ||
{name: 'debug', char: 'd', hidden: true}, | ||
{name: 'no-color', hidden: true} | ||
] | ||
module.exports = Command |
@@ -66,9 +66,12 @@ 'use strict' | ||
this.action = message => { | ||
if (!this.displayAction) this.writeError(`${message}...`) | ||
else if (this.action.spinner) { | ||
this.action.spinner.text = `${message}...` | ||
if (this.action.task) { | ||
if (this.action.task.spinner) this.action.task.spinner.text = `${message}...` | ||
else process.stderr.write(`\n${message}...`) | ||
} else { | ||
const Spinner = require('./spinner') | ||
this.action.spinner = new Spinner({text: `${message}...`, command: this}) | ||
this.action.spinner.start() | ||
this.action.task = {text: `${message}...`, command: this} | ||
if (this.displaySpinner) { | ||
const Spinner = require('./spinner') | ||
this.action.task.spinner = new Spinner(this.action.task) | ||
this.action.task.spinner.start() | ||
} else this.writeError(this.action.task.text) | ||
} | ||
@@ -78,23 +81,29 @@ } | ||
this.action.status = status => { | ||
if (this.action.spinner) this.action.spinner.status = status | ||
if (!this.action.task) return | ||
if (this.action.task.spinner) this.action.task.spinner.status = status | ||
else process.stderr.write(` ${status}`) | ||
} | ||
this.action.done = (msg = 'done') => { | ||
if (this.action.spinner) { | ||
this.action.spinner.stop(msg) | ||
} else { | ||
if (this.slack) return this.log(msg) | ||
} | ||
this.action.spinner = null | ||
if (!this.action.task) return | ||
this.action.status(msg) | ||
if (this.action.task.spinner) this.action.task.spinner.stop(msg) | ||
else process.stderr.write('\n') | ||
delete this.action.task | ||
} | ||
this.action.pause = fn => { | ||
if (this.action.spinner) { | ||
this.action.spinner.stop() | ||
this.action.spinner.clear() | ||
if (this.action.task) { | ||
if (this.action.task.spinner) { | ||
this.action.task.spinner.stop() | ||
this.action.task.spinner.clear() | ||
} else { | ||
delete this.action.task | ||
process.stderr.write('\n') | ||
} | ||
} | ||
fn() | ||
if (this.action.spinner) { | ||
if (this.action.task && this.action.task.spinner) { | ||
process.stderr.write('\n') | ||
this.action.spinner.start() | ||
this.action.task.spinner.start() | ||
} | ||
@@ -104,3 +113,3 @@ } | ||
get displayAction () { | ||
get displaySpinner () { | ||
return !this[slack] && process.stdin.isTTY && process.stderr.isTTY && !process.env.CI && process.env.TERM !== 'dumb' | ||
@@ -120,3 +129,3 @@ } | ||
this.showCursor() | ||
if (this.action.spinner) this.action.done() | ||
this.action.done() | ||
if (this[slack]) { | ||
@@ -224,3 +233,3 @@ const slack = require('./slack') | ||
} else { | ||
if (this.action.spinner) this.action.done(this.color.bold.red('!')) | ||
if (this.action.task) this.action.done(this.color.bold.red('!')) | ||
if (this.debugging) console.error(err.stack) | ||
@@ -227,0 +236,0 @@ else console.error(bangify(wrap(getErrorMessage(err)), this.color.red(arrow))) |
@@ -28,2 +28,3 @@ 'use strict' | ||
if (this.id) return | ||
this.enabled = true | ||
this.stream.write(this.ansi.cursorLeft) | ||
@@ -30,0 +31,0 @@ this.stream.write(this.ansi.eraseLine) |
{ | ||
"name": "heroku-cli-command", | ||
"description": "base Heroku CLI command", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Jeff Dickey @dickeyxxx", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/heroku/heroku-cli-command/issues", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153842
2204
8