Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const formatLevel = ({ data: { level }, options: { colorize } }) => {
// Define existing levels
const levels = {
trace: [chalk.gray, figures.ellipsis],
debug: [chalk.cyan, figures.bullet],
info: [chalk.blue, figures.info],
warn: [chalk.yellow, figures.warning],
error: [chalk.red, figures.cross],
fatal: [chalk.red, figures.cross]
};
// Try calculating the current level index
const levelIndex = level / 10 - 1;
let levelString = Object.keys(levels)[levelIndex];
let [levelColor, levelFigure] = levels[levelString] || [null, null];
// Fallback for custom levels
if (!levelString || !levelColor) {
levelString = `custom`;
levelColor = chalk.magenta;
levelFigure = "★";
checkIntegrity() {
log(chalk.white.bold(figures.bullet + ' Check Integrity'), "\n");
let status = true;
return this.parseCsproj()
.then((fileIncludes) => {
let fileNotFound = [];
let duplicatedFiles = [];
fileNotFound = fileIncludes.filter(this.checkExist);
duplicatedFiles = fileIncludes.filter(this.checkDuplicated);
if (!fileNotFound || fileNotFound.length > 0) {
status = false;
log('');
log(chalk.white.bgRed.bold(figures.warning + ' There are files included that not exist: '));
fileNotFound.map((e) => log(chalk.yellow.underline(e)));
log('');
.map(enabled => (enabled ? figures.bullet : chalk.gray(figures.bullet)))
.join('');
renderStatus(task: TaskInterface): string {
switch (task.status) {
case STATUS_PENDING:
return chalk.gray(figures.bullet);
case STATUS_RUNNING:
return chalk.gray(task.spinner());
case STATUS_SKIPPED:
return chalk.yellow(figures.circleDotted);
case STATUS_PASSED:
return chalk.green(figures.tick);
case STATUS_FAILED:
return chalk.red(figures.cross);
default:
return '';
}
}
checkFiles(files) {
log(chalk.white.bold(figures.bullet + ' Check if files exist'), "\n");
return this.parseCsproj()
.then((fileIncludes) => {
return this.compareFiles(files, fileIncludes);
})
.then(function (result) {
if (!result || result.length > 0) {
log('');
log(chalk.white.bgRed.bold(figures.warning + ' Files that are not included: '));
result.map((e) => log(chalk.yellow.underline(e)));
log('');
return Promise.reject(false);
} else {
log('');
log(chalk.green.bold(figures.smiley + ' OK! All files are included! '));
export interface LoggerOptions {
verbose?: boolean;
}
interface LevelOptions {
level: Level;
color: Chalk;
icon: string;
verbose?: boolean;
}
const levelOptions: LevelOptions[] = [
{
level: Level.Debug,
color: chalk.gray,
icon: figures.bullet,
verbose: true
},
{ level: Level.Info, color: chalk.blue, icon: figures.info },
{ level: Level.Success, color: chalk.green, icon: figures.tick },
{ level: Level.Warn, color: chalk.yellow, icon: figures.warning },
{ level: Level.Error, color: chalk.red, icon: figures.cross }
];
const maxLevelLength = Math.max(
...levelOptions.map(getPrefix).map(stringWidth)
);
function getPrefix(opt: LevelOptions) {
return `${opt.icon} ${opt.level}`;
}
logLevel: 'warn'
},
complete: {
badge: figures.checkboxOn,
color: 'cyan',
label: 'complete',
logLevel: 'info'
},
pending: {
badge: figures.checkboxOff,
color: 'magenta',
label: 'pending',
logLevel: 'info'
},
note: {
badge: figures.bullet,
color: 'blue',
label: 'note',
logLevel: 'info'
},
start: {
badge: figures.play,
color: 'green',
label: 'start',
logLevel: 'info'
},
pause: {
badge: figures.squareSmallFilled,
color: 'yellow',
label: 'pause',
logLevel: 'info'
},