40 lines
571 B
JavaScript
40 lines
571 B
JavaScript
|
'use strict';
|
||
|
var restoreCursor = require('./restore-cursor');
|
||
|
|
||
|
var hidden = false;
|
||
|
|
||
|
exports.show = function (stream) {
|
||
|
var s = stream || process.stderr;
|
||
|
|
||
|
if (!s.isTTY) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
hidden = false;
|
||
|
s.write('\u001b[?25h');
|
||
|
};
|
||
|
|
||
|
exports.hide = function (stream) {
|
||
|
var s = stream || process.stderr;
|
||
|
|
||
|
if (!s.isTTY) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
restoreCursor();
|
||
|
hidden = true;
|
||
|
s.write('\u001b[?25l');
|
||
|
};
|
||
|
|
||
|
exports.toggle = function (force, stream) {
|
||
|
if (force !== undefined) {
|
||
|
hidden = force;
|
||
|
}
|
||
|
|
||
|
if (hidden) {
|
||
|
exports.show(stream);
|
||
|
} else {
|
||
|
exports.hide(stream);
|
||
|
}
|
||
|
};
|