Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.fail(function (msg, err, yargs) {
if (err) throw err // preserve stack
console.info(bgRed('You broke it!'))
console.info(red(msg))
console.error(green('You should be doing'), yargs.help())
process.exit(1)
}).argv
debug(argv)
emit: function (msg) {
// Log notification through console
var str = chalk.bgCyan('ws') +
chalk.bold.bgCyan(msg.title || '::')
switch (msg.emphasis) {
case 'error':
str = str + chalk.bgRed(msg.body)
break
case 'warning':
str = str + chalk.bgYellow(msg.body)
break
case 'info':
str = str + chalk.bgBlue(msg.body)
break
case 'success':
str = str + chalk.bgGreen(msg.body)
break
}
var client = mqtt.connect('ws://' + process.env.NETBEAST_URL + ':' + process.env.NETBEAST_PORT)
console.log(str)
client.publish('netbeast/push', JSON.stringify(msg))
client.end()
public error(...values: any[]): void {
try {
this.errStream.write(chalk.bgRed('ERROR') + ' ' + format(values) + '\n')
} catch (err) {
// ignore
}
}
}
exports.error = msg => {
console.error(format(chalk.bgRed(' ERROR '), chalk.red(msg)))
if (msg instanceof Error) {
console.error(msg.stack)
}
process.exit(1)
}
let facts = () => {
/**
* Check that the data exists.
*/
if (!_.isObject(data) && !_.isNil(data)) {
console.log(chalk.bgRed(`Couldn't load data.`));
return;
}
let uniqueArray = _.uniq(data.facts),
randomItem = _.sample(uniqueArray),
wordLimit = 7,
sentences = _.chunk(_.words(randomItem, /[^, ]+/g), wordLimit),
text = '';
/**
* Break up the string into sentences.
*/
_.forEach(sentences, (sentence, index) => {
text += `${_.join(sentence, ' ')}${sentences.length - 1 == index ? '' : '\n'}`;
});
function parseArgs() {
let settings = {};
if (argsNum === 2) {
return settings;
}
for (let i = 2; i < argsNum; i++) {
let arg = args[i].split('=');
let argKey = arg[0];
let argValue = arg[1];
if (allowed.indexOf(argKey) < 0) {
die(chalk.bgRed(`The argument ${chalk.italic(argKey)} is invalid`));
}
switch (argKey) {
case 'main':
case 'm':
settings.main = argValue;
break;
case 'css':
case 'c':
settings.css = argValue;
break;
case 'js':
case 'j':
settings.js = argValue;
break;
case 'static':
public format(logLevel: LogLevel, message: string) {
switch (logLevel) {
case 'emergency':
message = bgRed(message);
break;
case 'alert':
message = red.underline(message);
break;
case 'critical':
message = yellow.underline(message);
break;
case 'warning':
message = yellow(message);
break;
case 'notice':
message = magenta(message);
break;
case 'info':
message = blue(message);
break;
.then(choice => {
const result = step.options.find(
option => option.description === choice
);
return result.value;
});
case "text":
return new Input({
message: step.message,
initial: step.initial
})
.run()
.then(choice => choice || "");
default:
throw `${chalk.red("Error: option type:")} ${chalk.bgRed(
step.type
)} ${chalk.red("not found")}`;
}
}
exec(options.dlrCallback + " '" + dlr.toJson() + "'", function(err, stdout, stderr) {
if(err) {
return log(chalk.bgRed('Something went wrong executing the DRL callback'));
}
log(chalk.green('Executed callback successfully'));
});