Innovenergy_trunk/frontend/node_modules/testcafe/lib/cli/log.js

45 lines
4.9 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tty_1 = __importDefault(require("tty"));
const elegant_spinner_1 = __importDefault(require("elegant-spinner"));
const log_update_async_hook_1 = __importDefault(require("log-update-async-hook"));
const chalk_1 = __importDefault(require("chalk"));
const is_ci_1 = __importDefault(require("is-ci"));
// NOTE: To support piping, we use stderr as the log output
// stream, while stdout is used for the report output.
exports.default = {
animation: null,
isAnimated: tty_1.default.isatty(1) && !is_ci_1.default,
showSpinner() {
// NOTE: we can use the spinner only if stdout is a TTY and we are not in CI environment (e.g. TravisCI),
// otherwise we can't repaint animation frames. Thanks https://github.com/sindresorhus/ora for insight.
if (this.isAnimated) {
const spinnerFrame = (0, elegant_spinner_1.default)();
this.animation = setInterval(() => {
const frame = chalk_1.default.cyan(spinnerFrame());
(0, log_update_async_hook_1.default)(frame);
}, 50);
}
},
hideSpinner(isExit) {
if (this.animation) {
clearInterval(this.animation);
log_update_async_hook_1.default.clear();
if (isExit)
log_update_async_hook_1.default.done();
this.animation = null;
}
},
write(text) {
if (this.animation)
this.hideSpinner();
console.log(text);
if (this.animation)
this.showSpinner();
},
};
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS9sb2cuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSw4Q0FBc0I7QUFDdEIsc0VBQTZDO0FBQzdDLGtGQUE4QztBQUM5QyxrREFBMEI7QUFDMUIsa0RBQXlCO0FBRXpCLDJEQUEyRDtBQUMzRCxzREFBc0Q7QUFDdEQsa0JBQWU7SUFDWCxTQUFTLEVBQUcsSUFBS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