@ms-cloudpack/task-reporter
Advanced tools
Comparing version 0.4.3 to 0.5.0
@@ -1,6 +0,1 @@ | ||
/** | ||
* Sets the mode of ansi helpers. Disabling ansi is useful for text-only scenarios where | ||
* ansi codes can't be processed. | ||
*/ | ||
export declare function disableAnsi(disabled: boolean): void; | ||
export declare function moveUpLines(count?: number): void; | ||
@@ -7,0 +2,0 @@ export declare function moveDownLines(count?: number): void; |
@@ -1,2 +0,2 @@ | ||
export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, disableAnsi, white, yellow, } from './ansiHelpers.js'; | ||
export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, white, yellow, } from './ansiHelpers.js'; | ||
export { bulletedList, type BulletList } from './bulletedList.js'; | ||
@@ -3,0 +3,0 @@ export { debugLoggingConfig, defaultLoggingConfig, noLoggingConfig, verboseLoggingConfig } from './configs.js'; |
@@ -23,4 +23,3 @@ import { TaskReporterTask, type TaskReporterTaskResult } from './TaskReporterTask.js'; | ||
/** | ||
* Plain text mode. This will disable all colors and formatting which depends | ||
* on ansi codes, including stickies. | ||
* Plain text mode. This will disable sticky rendering which requires ansi support. | ||
*/ | ||
@@ -98,4 +97,9 @@ plainTextMode?: boolean; | ||
private _hasCompleted; | ||
private _ignoredLogMessages; | ||
constructor(options?: TaskReporterOptions); | ||
/** | ||
* Add a partial string to match on console logging. When found, we ignore the message. | ||
*/ | ||
ignoreLogMessage(partialMatch: string): void; | ||
/** | ||
* Set options. | ||
@@ -102,0 +106,0 @@ */ |
@@ -1,6 +0,1 @@ | ||
/** | ||
* Sets the mode of ansi helpers. Disabling ansi is useful for text-only scenarios where | ||
* ansi codes can't be processed. | ||
*/ | ||
export declare function disableAnsi(disabled: boolean): void; | ||
export declare function moveUpLines(count?: number): void; | ||
@@ -7,0 +2,0 @@ export declare function moveDownLines(count?: number): void; |
import { write } from './write.js'; | ||
const ansiEscape = '\x1b['; | ||
let ansiDisabled = false; | ||
const isAnsiDisabled = process.argv.includes('--no-color') || process.argv.includes('-n'); | ||
const ansiCodes = { | ||
@@ -30,9 +30,2 @@ bold: `${ansiEscape}1m`, | ||
}; | ||
/** | ||
* Sets the mode of ansi helpers. Disabling ansi is useful for text-only scenarios where | ||
* ansi codes can't be processed. | ||
*/ | ||
export function disableAnsi(disabled) { | ||
ansiDisabled = disabled; | ||
} | ||
/* | ||
@@ -42,3 +35,3 @@ * Moves the cursor up N lines. | ||
export function moveUpLines(count = 1) { | ||
if (ansiDisabled) { | ||
if (isAnsiDisabled) { | ||
return; | ||
@@ -54,3 +47,3 @@ } | ||
export function moveDownLines(count = 1) { | ||
if (ansiDisabled) { | ||
if (isAnsiDisabled) { | ||
return; | ||
@@ -69,3 +62,3 @@ } | ||
} | ||
if (ansiDisabled) { | ||
if (isAnsiDisabled) { | ||
return text; | ||
@@ -88,3 +81,3 @@ } | ||
export function clearLine() { | ||
if (ansiDisabled) { | ||
if (isAnsiDisabled) { | ||
return; | ||
@@ -99,3 +92,3 @@ } | ||
} | ||
if (ansiDisabled) { | ||
if (isAnsiDisabled) { | ||
return String(text); | ||
@@ -102,0 +95,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, disableAnsi, white, yellow, } from './ansiHelpers.js'; | ||
export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, white, yellow, } from './ansiHelpers.js'; | ||
export { bulletedList, type BulletList } from './bulletedList.js'; | ||
@@ -3,0 +3,0 @@ export { debugLoggingConfig, defaultLoggingConfig, noLoggingConfig, verboseLoggingConfig } from './configs.js'; |
@@ -1,2 +0,2 @@ | ||
export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, disableAnsi, white, yellow, } from './ansiHelpers.js'; | ||
export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, white, yellow, } from './ansiHelpers.js'; | ||
export { bulletedList } from './bulletedList.js'; | ||
@@ -3,0 +3,0 @@ export { debugLoggingConfig, defaultLoggingConfig, noLoggingConfig, verboseLoggingConfig } from './configs.js'; |
@@ -23,4 +23,3 @@ import { TaskReporterTask, type TaskReporterTaskResult } from './TaskReporterTask.js'; | ||
/** | ||
* Plain text mode. This will disable all colors and formatting which depends | ||
* on ansi codes, including stickies. | ||
* Plain text mode. This will disable sticky rendering which requires ansi support. | ||
*/ | ||
@@ -98,4 +97,9 @@ plainTextMode?: boolean; | ||
private _hasCompleted; | ||
private _ignoredLogMessages; | ||
constructor(options?: TaskReporterOptions); | ||
/** | ||
* Add a partial string to match on console logging. When found, we ignore the message. | ||
*/ | ||
ignoreLogMessage(partialMatch: string): void; | ||
/** | ||
* Set options. | ||
@@ -102,0 +106,0 @@ */ |
import { Writer } from './Writer.js'; | ||
import { darkGrey, green, lightRed, red, yellow, white, bold, blue, cyan, magenta, disableAnsi, } from './ansiHelpers.js'; | ||
import { darkGrey, green, lightRed, red, yellow, white, bold, blue, cyan, magenta } from './ansiHelpers.js'; | ||
import { TaskReporterTask } from './TaskReporterTask.js'; | ||
@@ -56,2 +56,3 @@ import { makeValuesUniformLength } from './makeValuesUniformLength.js'; | ||
constructor(options = {}) { | ||
this._ignoredLogMessages = []; | ||
this._options = options; | ||
@@ -70,2 +71,8 @@ this._writer = new Writer(); | ||
/** | ||
* Add a partial string to match on console logging. When found, we ignore the message. | ||
*/ | ||
ignoreLogMessage(partialMatch) { | ||
this._ignoredLogMessages.push(partialMatch); | ||
} | ||
/** | ||
* Set options. | ||
@@ -76,3 +83,2 @@ */ | ||
this._options = { ...options }; | ||
disableAnsi(!!options.plainTextMode); | ||
if (previousOptions.productName !== options.productName) { | ||
@@ -165,3 +171,6 @@ this._reportProductInfo(); | ||
if (this._options[optionName]) { | ||
this._reportConsoleLog(status, args); | ||
const filteredArgs = this._ignoredLogMessages.length === 0 | ||
? args | ||
: args.filter((arg) => !this._ignoredLogMessages.find((substring) => typeof arg === 'string' && arg.indexOf(substring) >= 0)); | ||
this._reportConsoleLog(status, filteredArgs); | ||
} | ||
@@ -192,3 +201,5 @@ }; | ||
const messageType = statusMessage[status] || statusMessage.default; | ||
this._writer.write(`${darkGrey(`[${getTimestamp()}]`)} ${char} ${bold(color(messageType))} ${args.join(' ')}`); | ||
if (args.length) { | ||
this._writer.write(`${darkGrey(`[${getTimestamp()}]`)} ${char} ${bold(color(messageType))} ${args.join(' ')}`); | ||
} | ||
} | ||
@@ -201,3 +212,3 @@ _reportTaskComplete(task) { | ||
const messageType = color(statusMessage[task.status] || statusMessage.default); | ||
const resultDetails = task.message ? `- ${task.message}` : ''; | ||
const resultDetails = task.message ? `${task.message[0] === '\n' ? '' : '- '}${task.message}` : ''; | ||
const resultDuration = task.duration && task.status !== 'abort' ? `(${formatTime(task.duration)})` : ''; | ||
@@ -204,0 +215,0 @@ this._writer.write(`${darkGrey(`[${getTimestamp()}]`)} ${char} ${messageType} ${task.name} ${resultDetails} ${darkGrey(resultDuration)}`); |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.35.4" | ||
"packageVersion": "7.36.0" | ||
} | ||
] | ||
} |
{ | ||
"name": "@ms-cloudpack/task-reporter", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "Helpers for logging tasks to the console.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
229534
2298