Skip to content

Commit

Permalink
Added support for interactive mode. Fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBruno authored and klaudiosinani committed May 31, 2018
1 parent 608f882 commit 48948a1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion signale.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const timeSpan = then => {

class Signale {
constructor(options = {}) {
this._interactive = options.interactive || false;
this._config = Object.assign(this.packageConfiguration, options.config);
this._customTypes = Object.assign({}, options.types);
this._scopeName = options.scope || '';
Expand Down Expand Up @@ -83,10 +84,19 @@ class Signale {

_log(message, streams = this._stream) {
this._formatStream(streams).forEach(stream => {
stream.write(message + '\n');
this._write(stream, message);
});
}

_write(stream, message) {
if (this._interactive) {
stream.moveCursor(0, -1);
stream.clearLine();
stream.cursorTo(0);
}
stream.write(message + '\n');
}

_formatStream(stream) {
return Array.isArray(stream) ? stream : [stream];
}
Expand Down

0 comments on commit 48948a1

Please sign in to comment.