Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const log = logger("sender test", false);
// we can't snapshot because of logSymbols & colors...
const colorStart =
process.platform !== "win32" && !process.env.CIRCLECI ? "[90m" : "";
const colorEnd =
process.platform !== "win32" && !process.env.CIRCLECI ? "[39m" : "";
expect(log("test msg")).toBe(
`${logSymbols.info} ${colorStart}sender test:${colorEnd} test msg`,
);
expect(log.debug("test debug")).toBe(
` ${colorStart}sender test:${colorEnd} test debug`,
);
expect(log.info("test info")).toBe(
`${logSymbols.info} ${colorStart}sender test:${colorEnd} test info`,
);
expect(log.success("test success")).toBe(
`${logSymbols.success} ${colorStart}sender test:${colorEnd} test success`,
);
expect(log.warn("test warning")).toBe(
`${logSymbols.warning} ${colorStart}sender test:${colorEnd} test warning`,
);
expect(log.error("test error")).toBe(
`${logSymbols.error} ${colorStart}sender test:${colorEnd} test error`,
);
});
export function printGeneralInfoMessage(msg: string, symbol?: string) {
if (typeof symbol === 'undefined') {
// eslint-disable-next-line no-param-reassign
symbol = logSymbols.info;
}
console.info(addTimeStampToLog(`${symbol} ${msg}`));
}
properSymbol( hasErrors: boolean, hasWarnings: boolean ): any {
if ( hasErrors ) {
return this.symbolError;
}
if ( hasWarnings ) {
return this.symbolWarning;
}
return this.symbolSuccess;
}
readonly symbolPointer = figures.pointerSmall;
readonly symbolItem = figures.line;
readonly symbolSuccess = logSymbols.success;
readonly symbolError = logSymbols.error;
readonly symbolWarning = logSymbols.warning;
readonly symbolInfo = logSymbols.info;
readonly colorSuccess = this.colors.greenBright; // this.colors.rgb(0, 255, 0);
readonly colorError = this.colors.redBright; // this.colors.rgb(255, 0, 0);
readonly colorWarning = this.colors.yellow;
readonly colorInfo = this.colors.gray;
readonly colorHighlight = this.colors.yellowBright; // this.colors.rgb(255, 242, 0);
readonly colorText = this.colors.white;
readonly bgSuccess = this.colors.bgGreenBright;
readonly bgError = this.colors.bgRedBright;
readonly bgWarning = this.colors.bgYellow;
readonly bgInfo = this.colors.bgBlackBright; // bgGray does not exist in chalk
readonly bgHighlight = this.colors.bgYellowBright;
readonly bgText = this.colors.bgWhiteBright;
}
.then(pkg => {
console.log(`${logSymbols.info} ${pkg.name}@${pkg.version} created 🎉 .`);
})
.catch(err => {
export function info(text, code) {
process.stderr.write(`${logSymbols.info}${chalk.blue(' INFO ')}${text}\n`)
code && process.exit(code)
}
require('colors')
var
log,
symbols = require('log-symbols'),
messageTypes = {
success: symbols.success,
error: symbols.error,
info: symbols.info,
warning: symbols.warning,
debug: '[DEBUG]'.gray
}
function showMessage () {
var
array,
args = [].slice.call(arguments)
if (args[0].length === 0) {
return console.log()
}
array = [].slice.call(args[0])
if (args.length === 2) {
global.logTime = function() {
info(logSymbols.info + (' [' + moment().format('YY.MM.DD HH:mm:ss') + '] ').gray + Array.prototype.join.call(arguments, ' '));
};
global.logDoc = function() {
module.exports.info = (...args) => log(...[logSymbols.info].concat(args));
module.exports.log = log;
const dir = answer.botName
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
log(`${logSymbols.info} Creating new folder...`)
fs.writeFile(`${dir}/package.json`, getPackage(dir), err => {
if (err)
return log(`${logSymbols.error} Error at creating package.json`)
})
log(`${logSymbols.info} Creating bot.js...`)
fs.writeFile(`${dir}/bot.js`, getScript(answer.token, dir), err => {
if (err)
return log(`${logSymbols.error} Error at bot.js creation`)
})
log(`${logSymbols.info} Generating .gitignore...`)
fs.writeFile(`${dir}/.gitignore`, getGitignore(), err => {
if (err)
return log(`${logSymbols.error} Error at .gitignore creation`)
})
log(`${logSymbols.info} Writing README.md...`)
fs.writeFile(`${dir}/README.md`, getReadme(dir), err => {
if (err)
return log(`${logSymbols.error} Error at README creation`)
})
log(`${logSymbols.info} Installing dependencies...`)
exec(`cd ${dir} && npm install`, (err, stdout, stderr) => {
log(`${logSymbols.success} Done!`)
})
}