flex-plugins-utils-logger
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -7,4 +7,11 @@ import chalk from 'chalk'; | ||
isTrace?: boolean; | ||
markdown?: boolean; | ||
} | ||
declare class Logger { | ||
private static boldRegexMatcher; | ||
private static boldRegexReplacer; | ||
private static italicRegexMatcher; | ||
private static italicRegexReplacer; | ||
private static codeRegexMatcher; | ||
private static codeRegexReplacer; | ||
private readonly options; | ||
@@ -22,2 +29,3 @@ constructor(options?: LoggerOptions); | ||
clearTerminal: (forced?: boolean) => void; | ||
markdown: (msg?: string | undefined) => string | undefined; | ||
private _log; | ||
@@ -40,2 +48,3 @@ private isDebug; | ||
clearTerminal: (forced?: boolean) => void; | ||
markdown: (msg?: string | undefined) => string | undefined; | ||
Logger: typeof Logger; | ||
@@ -42,0 +51,0 @@ wrap: (input: string, columns: number, options?: { |
@@ -29,2 +29,3 @@ "use strict"; | ||
var wrap_ansi_1 = __importDefault(require("wrap-ansi")); | ||
var pipe_compose_1 = require("@k88/pipe-compose"); | ||
var env_1 = __importDefault(require("./env")); | ||
@@ -107,7 +108,26 @@ var DefaultWrapOptions = { hard: true }; | ||
}; | ||
this.markdown = function (msg) { | ||
if (!msg || msg === '') { | ||
return msg; | ||
} | ||
var bold = msg.match(Logger.boldRegexMatcher); | ||
if (bold) { | ||
return _this.markdown(msg.replace(Logger.boldRegexReplacer, chalk_1.default.bold(bold[0]))); | ||
} | ||
var italic = msg.match(Logger.italicRegexMatcher); | ||
if (italic) { | ||
return _this.markdown(msg.replace(Logger.italicRegexReplacer, chalk_1.default.italic(italic[0]))); | ||
} | ||
var code = msg.match(Logger.codeRegexMatcher); | ||
if (code) { | ||
return _this.markdown(msg.replace(Logger.codeRegexReplacer, chalk_1.default.magenta(code[0]))); | ||
} | ||
return msg; | ||
}; | ||
this._log = function (args) { | ||
var color = args.color ? chalk_1.default[args.color] : null; | ||
var msg = util_1.format.apply({}, args.args); | ||
if (!_this.isQuiet() || args.level === 'error') { | ||
console[args.level]((color && color(msg)) || msg); | ||
var log = console[args.level]; | ||
var color = args.color ? chalk_1.default[args.color] : function (msg) { return msg; }; | ||
var msg = util_1.format.apply({}, args.args); | ||
pipe_compose_1.pipe(msg, color, _this.markdown, log); | ||
} | ||
@@ -135,2 +155,8 @@ }; | ||
} | ||
Logger.boldRegexMatcher = /(?<=\*{2})(.*?)(?=\*{2})/; | ||
Logger.boldRegexReplacer = /\*{2}(.*?)\*{2}/; | ||
Logger.italicRegexMatcher = /(?<=\*)(.*?)(?=\*)/; | ||
Logger.italicRegexReplacer = /\*(.*?)\*/; | ||
Logger.codeRegexMatcher = /(?<=\{{2})(.*?)(?=\}{2})/; | ||
Logger.codeRegexReplacer = /\{{2}(.*?)\}{2}/; | ||
return Logger; | ||
@@ -143,3 +169,3 @@ }()); | ||
exports._logger = new Logger(); | ||
var debug = exports._logger.debug, info = exports._logger.info, warning = exports._logger.warning, error = exports._logger.error, trace = exports._logger.trace, success = exports._logger.success, newline = exports._logger.newline, notice = exports._logger.notice, installInfo = exports._logger.installInfo, clearTerminal = exports._logger.clearTerminal; | ||
var debug = exports._logger.debug, info = exports._logger.info, warning = exports._logger.warning, error = exports._logger.error, trace = exports._logger.trace, success = exports._logger.success, newline = exports._logger.newline, notice = exports._logger.notice, installInfo = exports._logger.installInfo, clearTerminal = exports._logger.clearTerminal, markdown = exports._logger.markdown; | ||
exports.default = { | ||
@@ -156,2 +182,3 @@ debug: debug, | ||
clearTerminal: clearTerminal, | ||
markdown: markdown, | ||
Logger: Logger, | ||
@@ -158,0 +185,0 @@ wrap: wrap, |
@@ -51,2 +51,3 @@ "use strict"; | ||
var env_1 = __importDefault(require("./env")); | ||
var logger_1 = __importDefault(require("./logger")); | ||
exports._getSpinner = function (text, disabled) { | ||
@@ -76,3 +77,3 @@ if (disabled) { | ||
case 0: | ||
spinner = exports._getSpinner(title, disabled); | ||
spinner = exports._getSpinner(logger_1.default.markdown(title) || '', disabled); | ||
_a.label = 1; | ||
@@ -79,0 +80,0 @@ case 1: |
{ | ||
"name": "flex-plugins-utils-logger", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Flex Plugins Logger", | ||
@@ -43,2 +43,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@k88/pipe-compose": "^2.2.0", | ||
"boxen": "^4.1.0", | ||
@@ -55,3 +56,3 @@ "chalk": "^4.0.0", | ||
}, | ||
"gitHead": "d883d5aae90b8d528c45dd0281704726073554f6" | ||
"gitHead": "0151ee981516c9bcf1c4ee948288efb726f1fdbb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37586
576
7
+ Added@k88/pipe-compose@^2.2.0
+ Added@k88/pipe-compose@2.5.0(transitive)