forked from DevExpress/testcafe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DevExpress#193 from inikulin/gh192
Implement correct CLI coloring and logging. Get rid of `--report-path` option, since report can now be saved via piping (fixes DevExpress#192)
- Loading branch information
Showing
7 changed files
with
60 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import tty from 'tty'; | ||
import elegantSpinner from 'elegant-spinner'; | ||
import logUpdate from 'log-update'; | ||
import chalk from 'chalk'; | ||
|
||
// NOTE: To support piping, we use stderr as the log output | ||
// stream, while stdout is used for the report output. | ||
export default { | ||
animation: null, | ||
isTTY: tty.isatty(1), | ||
|
||
showSpinner () { | ||
// NOTE: we can use the spinner only if stderr is a TTY, | ||
// otherwise we can't repaint animation frames | ||
if (this.isTTY) { | ||
var spinnerFrame = elegantSpinner(); | ||
|
||
this.animation = setInterval(() => { | ||
var frame = chalk.cyan(spinnerFrame()); | ||
|
||
logUpdate.stderr(frame); | ||
}, 50); | ||
} | ||
}, | ||
|
||
hideSpinner () { | ||
if (this.animation) { | ||
clearInterval(this.animation); | ||
logUpdate.stderr.clear(); | ||
|
||
this.animation = null; | ||
} | ||
}, | ||
|
||
write (text) { | ||
console.error(text); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters