github-pages-deploy-action/node_modules/cli-cursor/index.js

36 lines
617 B
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
'use strict';
const restoreCursor = require('restore-cursor');
2020-03-31 20:40:00 +08:00
let isHidden = false;
2020-03-07 11:45:40 +08:00
2020-03-31 20:40:00 +08:00
exports.show = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
2020-03-07 11:45:40 +08:00
return;
}
2020-03-31 20:40:00 +08:00
isHidden = false;
writableStream.write('\u001B[?25h');
2020-03-07 11:45:40 +08:00
};
2020-03-31 20:40:00 +08:00
exports.hide = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
2020-03-07 11:45:40 +08:00
return;
}
restoreCursor();
2020-03-31 20:40:00 +08:00
isHidden = true;
writableStream.write('\u001B[?25l');
2020-03-07 11:45:40 +08:00
};
2020-03-31 20:40:00 +08:00
exports.toggle = (force, writableStream) => {
2020-03-07 11:45:40 +08:00
if (force !== undefined) {
2020-03-31 20:40:00 +08:00
isHidden = force;
2020-03-07 11:45:40 +08:00
}
2020-03-31 20:40:00 +08:00
if (isHidden) {
exports.show(writableStream);
2020-03-07 11:45:40 +08:00
} else {
2020-03-31 20:40:00 +08:00
exports.hide(writableStream);
2020-03-07 11:45:40 +08:00
}
};