Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
watchItem.watcher = fs.watch(fName, (eventType) => {
const relPath = path.relative(process.cwd(), fName);
broker.logger.info(kleur.magenta().bold(`The '${relPath}' file is changed. (Event: ${eventType})`));
// Clear from require cache
clearRequireCache(fName);
if (watchItem.others.length > 0) {
watchItem.others.forEach(f => clearRequireCache(f));
}
if (watchItem.brokerRestart && broker.runner && _.isFunction(broker.runner.restartBroker)) {
broker.logger.info(kleur.bgMagenta().white().bold("Action: Restart broker..."));
stopAllFileWatcher(projectFiles);
// Clear the whole require cache
require.cache.length = 0;
return broker.runner.restartBroker();
} else if (watchItem.allServices) {
// Reload all services
const [asset_name, asset_url] = is_ebook
? [
safe_name(`${lecture_index} ${asset['title']}.pdf`),
asset['asset']['url_set']['E-Book'][0]['file']
]
: [
safe_name(`${lecture_index} ${asset['filename']}`),
asset['url_set']['File'][0]['file']
];
const asset_name_with_path = path.join(chapter_path, asset_name);
const asset_id = asset['id'];
const asset_size = asset['file_size'];
if (fs.existsSync(asset_name_with_path)) {
is_ebook
? console.log(`\n ${magenta().inverse(' Lecture ')} ${asset_name} ${yellow('(already downloaded)')}`)
: console.log(`\n ${gray(inverse(' Asset '))} ${asset_name} ${yellow('(already downloaded)')}`);
} else {
await save_asset({
is_ebook,
asset_url,
asset_name,
asset_id,
asset_size,
chapter_path,
lecture_index
}).catch(error => {
is_ebook
? process.stderr.write(`\n ${magenta().inverse(' Lecture ')} ${asset_name}`)
: process.stderr.write(`\n ${gray(inverse(' Asset '))} ${asset_name}`);
throw error;
labelsToStr(labels) {
const keys = Object.keys(labels);
if (keys.length == 0)
return kleur.gray("{}");
return kleur.gray("{") + keys.map(key => `${kleur.gray(this.formatLabelName(key))}: ${kleur.magenta(labels[key])}`).join(", ") + kleur.gray("}");
}
function toTime() {
return '[' + colors.magenta(stamp()) + '] ';
}
import kleur from 'kleur'
import { list, identity } from './util'
const defaultOptions = {
code: kleur.yellow,
blockquote: kleur.gray().bgWhite().italic,
html: kleur.gray,
heading: kleur.green().bold,
firstHeading: kleur.magenta().underline().bold,
hr: kleur.reset,
listitem: kleur.reset,
list: list,
table: kleur.reset,
paragraph: identity,
strong: kleur.bold,
em: kleur.italic,
codespan: kleur.yellow,
del: kleur.dim().gray().strikethrough,
link: kleur.blue,
href: kleur.blue().underline,
text: identity,
unescape: true,
emoji: true,
width: 80,
showSectionPrefix: true,
toString() {
return kleur.magenta(_.padStart(this.method, 6)) + " " + kleur.cyan(this.fullPath) + kleur.grey(" => ") + (this.handler != null && this.type !== "multipart" ? "" : this.action);
}
prepareValueDump(indent, originalValue) {
let displayType = '';
let displayValue = '';
const paramType = kindOf(originalValue);
switch (paramType) {
case 'array':
case 'object':
displayType = '';
displayValue = this.generateDump(originalValue, `${indent}${this.spaces}`);
break;
case 'boolean':
displayType = 'boolean';
displayValue = magenta(`${originalValue}`);
break;
case 'string':
displayType = 'string';
displayValue = `${red(`"${originalValue}"`)} (length=${originalValue.length})`;
break;
case 'null':
displayValue = blue('null');
break;
case 'undefined':
displayValue = blue('undefined');
break;
case 'number':
displayType = Number.isInteger(originalValue) ? 'int' : 'float';
displayValue = green(originalValue);
break;
case 'function':
const addCompilerPrefix = msg =>
name ? bold(magenta(name + ': ')) + msg : msg;
if (field === 'errors' && stats.hasErrors()) {
hello(ctx, res) {
broker.logger.info(kleur.magenta(" After hook"));
return res;
}
},
"user.created"(ctx) {
this.logger.info(kleur.magenta(`${this.broker.nodeID}:${this.fullName}:mixin: Event '${ctx.eventName}' received. Payload:`), ctx.params, ctx.meta);
}
}