Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If this is false, stream was changed since validation
if (erroredLine) {
var errorColumn = message.lastColumn;
// Trim before if the error is too late in the line
if (errorColumn > 60) {
erroredLine = erroredLine.slice(errorColumn - 50);
errorColumn = 50;
}
// Trim after so the line is not too long
erroredLine = erroredLine.slice(0, 60);
// Highlight character with error
erroredLine =
colors.grey(erroredLine.substring(0, errorColumn - 1)) +
colors.bold(colors.red(erroredLine[ errorColumn - 1 ])) +
colors.grey(erroredLine.substring(errorColumn));
}
if (typeof(message.lastLine) !== 'undefined' || typeof(lastColumn) !== 'undefined') {
fancyLog(type, file.relative, location, message.message);
} else {
fancyLog(type, file.relative, message.message);
}
if (erroredLine) {
fancyLog(erroredLine);
}
});
async function step(actor, message, context = '') {
let prefix
prefix = actor.padEnd(7)
if (context) context = c.italic(` <${context}>`)
if (actor === 'alice') prefix = c.cyan(prefix)
else if (actor === 'bob') prefix = c.magenta(prefix)
else if (actor === 'charlie') prefix = c.yellow(prefix)
console.log(`${prefix}${context} ${c.grey(message)}`)
if (settings.DEBUG_MODE) {
await utils.delay(2000)
}
}
}, function () {
if (log) {
if (entry.totalCount === 1) {
fancyLog(`Stats for '${ansiColors.grey(entry.name)}': ${Math.round(entry.totalSize / 1204)}KB`);
} else {
const count = entry.totalCount < 100
? ansiColors.green(entry.totalCount.toString())
: ansiColors.red(entry.totalCount.toString());
fancyLog(`Stats for '${ansiColors.grey(entry.name)}': ${count} files, ${Math.round(entry.totalSize / 1204)}KB`);
}
}
this.emit('end');
});
}
function info(url) {
stderr(colors.grey(url));
}
toString(pretty?: boolean): string {
if (!pretty) {
if (this.totalCount === 1) {
return `${this.name}: ${this.totalSize} bytes`;
} else {
return `${this.name}: ${this.totalCount} files with ${this.totalSize} bytes`;
}
} else {
if (this.totalCount === 1) {
return `Stats for '${ansiColors.grey(this.name)}': ${Math.round(this.totalSize / 1204)}KB`;
} else {
const count = this.totalCount < 100
? ansiColors.green(this.totalCount.toString())
: ansiColors.red(this.totalCount.toString());
return `Stats for '${ansiColors.grey(this.name)}': ${count} files, ${Math.round(this.totalSize / 1204)}KB`;
}
}
}
}
function debug(msg) {
log(colors.grey(msg));
}
let styledOptions = options.map((option) => {
if (option === selected) return c.bold.green(option)
else return c.grey(option)
})
return `${c.grey('[')}${styledOptions.join(c.grey('|'))}${c.grey(']')}`