Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function startChat(user) {
// replace selector with selected user
let user_chat_selector = selector.user_chat;
user_chat_selector = user_chat_selector.replace('XXX', user);
await page.waitFor(user_chat_selector);
await page.click(user_chat_selector);
await page.click(selector.chat_input);
let name = getCurrentUserName();
if (name) {
console.log(logSymbols.success, chalk.bgGreen('You can chat now :-)'));
console.log(logSymbols.info, chalk.bgRed('Press Ctrl+C twice to exit any time.\n'));
} else {
console.log(logSymbols.warning, 'Could not find specified user "' + user + '"in chat threads\n');
}
}
var lines = []
// Filename
lines.push(colors.magenta.underline(path.relative(appRoot.path, filepath)))
// Loop file specific error/warning messages
data.results.forEach(function (file) {
file.messages.forEach(function (msg) {
var context = colors.yellow((options.showFilePath ? filepath + ':' : 'line ') + msg.line + ':' + msg.column)
var message = colors.cyan(msg.message + (options.showRuleNames ? ' (' + msg.ruleId + ')' : ''))
lines.push(context + '\t' + message)
})
})
// Error/Warning count
lines.push(logSymbols.error + ' ' + colors.red(data.errorCount + ' error' + (data.errorCount === 1 ? 's' : '')) + '\t' + logSymbols.warning + ' ' + colors.yellow(data.warningCount + ' warning' + (data.errorCount === 1 ? 's' : '')))
return lines.join('\n') + '\n'
}
prevfile = el.file;
return line;
}), {
stringLength: stringLength
}).split('\n').map(function (el, i) {
return headers[i] ? '\n' + chalk.underline(headers[i]) + '\n' + el : el;
}).join('\n') + '\n\n';
if (total > 0) {
if (errorCount > 0) {
ret += ' ' + logSymbols.error + ' ' + errorCount + pluralize(' error', errorCount) + (warningCount > 0 ? '\n' : '');
}
ret += ' ' + logSymbols.warning + ' ' + warningCount + pluralize(' warning', total);
} else {
ret += ' ' + logSymbols.success + ' No problems';
ret = '\n' + ret.trim();
}
console.log(ret + '\n');
}
};
utils.rename = function rename(src, dest, opts) {
opts = opts || {};
if (path.resolve(src) === path.resolve(dest)) {
if (opts.silent !== true) {
console.log(symbol.warning, bold(src), 'and', bold(dest), 'are the same path.');
}
} else if (!fs.existsSync(src)) {
if (opts.silent !== true) {
console.log(symbol.error, bold(src), 'does not exist.');
}
} else if (fs.existsSync(dest) && opts.force !== true) {
if (opts.silent !== true) {
console.log(symbol.warning, bold(dest), 'already exists (to force, pass `true` as the last argument).');
}
} else {
console.log(symbol.success, 'renamed', bold(src), '=>', bold(dest));
fs.renameSync(src, dest);
}
};
exports.warn = message => {
console.warn(symbols.warning, message)
}
function getSymbol(level: CriticalityLevel): string {
const symbols = {
[CriticalityLevel.Dangerous]: logSymbols.warning,
[CriticalityLevel.Breaking]: logSymbols.error,
[CriticalityLevel.NonBreaking]: logSymbols.success
};
return symbols[level];
}
function promptForWildcardConfirmation(origin, context) {
const {prompt, output, chalk} = context
output.print('')
output.print(chalk.yellow(`${logSymbols.warning} Warning: Examples of allowed origins:`))
if (origin === '*') {
output.print('- http://www.some-malicious.site')
output.print('- https://not.what-you-were-expecting.com')
output.print('- https://high-traffic-site.com')
output.print('- http://192.168.1.1:8080')
} else {
output.print(`- ${origin.replace(/:\*/, ':1234').replace(/\*/g, 'foo')}`)
output.print(`- ${origin.replace(/:\*/, ':3030').replace(/\*/g, 'foo.bar')}`)
}
output.print('')
return prompt.single({
type: 'confirm',
message: oneline`
var dateFormat = 'HH:mm:ss';
var dateLog = '[' + moment().format(dateFormat) + ']';
if (stats.hasErrors()) {
var errLen = statsInfo.errors.length;
var logMsg = errLen + ' error' + (errLen > 1 ? 's' : '') + ' in compiling process.';
spinner.text = dateLog.grey + ' ' + logMsg.red;
spinner.fail();
spinner.text = '';
}
if (stats.hasWarnings()) {
var warnLen = statsInfo.warnings.length;
var _logMsg = warnLen + ' warning' + (warnLen > 1 ? 's' : '') + ' in compiling process.';
spinner.text = dateLog.grey + ' ' + _logMsg.yellow;
spinner.stopAndPersist(logSymbols.warning);
spinner.text = '';
}
formatOutput(stats);
break;
}
}
});
};
function printPrettyRouteInfo(
functions: ServerlessResourceConfig[],
assets: ServerlessResourceConfig[],
config: StartCliConfig
): string {
const functionHeading = chalk`{green.bold Twilio functions available:}`;
let functionInfo;
if (functions.length > 0) {
functionInfo = functions
.map((fn, idx) => {
const symbol = idx + 1 === functions.length ? '└──' : '├──';
return `${symbol} ${prettyPrintFunction(fn, config)}`;
})
.join('\n');
} else {
functionInfo = chalk` {yellow ${logSymbols.warning}} No functions found`;
}
const assetHeading = chalk`{green.bold Twilio assets available:}`;
let assetInfo;
if (assets.length > 0) {
assetInfo = assets
.map((asset, idx) => {
const symbol = idx + 1 === assets.length ? '└──' : '├──';
return `${symbol} ${prettyPrintAsset(asset, config)}`;
})
.join('\n');
} else {
assetInfo = chalk` {yellow ${logSymbols.warning}} No assets found`;
}
let ngrokInfo = '';
announcements.map(ann => {
if (versionInRange(ann)) {
const msg = parseMessage(ann);
if (ann.isCritical) {
alerts.push(`${logSymbols.error} ${chalk['red']('Alert')}: ${msg}`);
} else {
warnings.push(`${logSymbols.warning} ${chalk['yellow']('Warning')}: ${msg}`);
}
}
});