rush-init-project-plugin
Version:
Rush plugin for initialize project in monorepo
80 lines • 3.19 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLog = exports.TerminalSingleton = void 0;
var node_core_library_1 = require("@rushstack/node-core-library");
var TerminalSingleton = exports.TerminalSingleton = /** @class */ (function () {
function TerminalSingleton() {
}
TerminalSingleton.getInstance = function () {
if (!TerminalSingleton._instance) {
TerminalSingleton._instance = new node_core_library_1.Terminal(TerminalSingleton._terminalProvider);
}
return TerminalSingleton._instance;
};
TerminalSingleton.setVerboseEnabled = function (enabled) {
TerminalSingleton._terminalProvider.verboseEnabled = enabled;
};
TerminalSingleton._terminalProvider = new node_core_library_1.ConsoleTerminalProvider();
return TerminalSingleton;
}());
function createLog(logOption) {
var prefix = logOption.prefix, verboseEnabled = logOption.verboseEnabled;
// eslint-disable-next-line no-unused-expressions
if (typeof verboseEnabled === "boolean")
TerminalSingleton.setVerboseEnabled(verboseEnabled);
var terminal = TerminalSingleton.getInstance();
return {
info: function (msg) {
terminal.write({
text: "".concat(prefix, " "),
backgroundColor: node_core_library_1.ColorValue.Blue,
foregroundColor: node_core_library_1.ColorValue.Black,
});
terminal.writeLine({
text: msg,
textAttributes: [node_core_library_1.TextAttribute.Dim],
});
},
warn: function (msg) {
terminal.write({
text: "".concat(prefix, " "),
backgroundColor: node_core_library_1.ColorValue.Yellow,
foregroundColor: node_core_library_1.ColorValue.Black,
});
terminal.writeLine({
text: msg,
foregroundColor: node_core_library_1.ColorValue.Yellow,
});
},
error: function (msg) {
terminal.write({
text: "".concat(prefix, " "),
foregroundColor: node_core_library_1.ColorValue.White,
backgroundColor: node_core_library_1.ColorValue.Red,
});
terminal.writeLine({
text: msg,
foregroundColor: node_core_library_1.ColorValue.Red,
});
},
success: function (msg) {
terminal.write({
text: "".concat(prefix, " "),
foregroundColor: node_core_library_1.ColorValue.Black,
backgroundColor: node_core_library_1.ColorValue.Green,
});
terminal.writeLine({
text: msg,
foregroundColor: node_core_library_1.ColorValue.Green,
});
},
verbose: function (msg) {
terminal.writeVerboseLine({
text: "".concat(prefix, " ").concat(msg),
textAttributes: [node_core_library_1.TextAttribute.Dim],
});
},
};
}
exports.createLog = createLog;
//# sourceMappingURL=terminal.js.map