Created
September 6, 2018 03:29
-
-
Save mikeerickson/cd8986ef009932ca11037e1a2a653752 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chalk from "chalk"; | |
import * as dateFormat from "dateformat"; | |
// import { dump } from "dumper.js"; | |
const dump = require("dumper.js"); | |
/* eslint-disable-next-line */ | |
const log = console.log; | |
export default class Helpers { | |
public static passIcon = "✓"; | |
public static failIcon = "✖︎"; | |
public static info = chalk.bold.keyword("orange"); | |
public static header = chalk.cyan.bold; | |
public static subHeader = chalk.yellow; | |
public static optionHeader = chalk.magenta; | |
public static enabled = chalk.green; | |
public static disabled = chalk.grey.bold; | |
public static error = chalk.red.bold; | |
public static success = chalk.green.bold; | |
public static warning = chalk.yellow.bold; | |
public static errorLabel = chalk.bgRed.white.bold; | |
public static successLabel = chalk.white.bgGreen.bold; | |
public static infoLabel = chalk.bgKeyword("orange").black.bold; | |
public static logLabel = chalk.bgWhite.black.bold; | |
public static warningLabel = chalk.bgYellow.black.bold; | |
public static headerLabel = chalk.bgCyan.black.bold; | |
public static optionHeaderLabel = chalk.bgMagenta.black.bold; | |
public static timestamp = dateFormat(new Date(), "yyyy-mm-dd HH:MM:ss"); | |
public static debug(...args: string[]) { | |
if (process.env.NODE_ENV !== "production") { | |
log(chalk.grey(`[${this.timestamp}] ${args}`)); | |
} | |
} | |
public static log(...args: string[]) { | |
log(this.log(`[${this.timestamp}] ${args}`)); | |
} | |
public static logDebug(...args: string[]) { | |
if (process.env.NODE_ENV !== "production") { | |
log(chalk.grey(`[${this.timestamp}] ${args} `)); | |
} | |
} | |
public static logError(...args: string[]) { | |
log(this.error(`[${this.timestamp}] ${args}`)); | |
} | |
public static logSuccess(...args: string[]) { | |
log(this.success(`[${this.timestamp}] ${args} `)); | |
} | |
public static logWarning(...args: string[]) { | |
log(this.warning(`[${this.timestamp}] ${args}`)); | |
} | |
public static logInfo(...args: string[]) { | |
log(this.info(`[${this.timestamp}] ${args}`)); | |
} | |
public static logStatus(...args: string[]) { | |
log(this.header(`[${this.timestamp}] ${args}`)); | |
} | |
public static logSummary(label = "", msg = "") { | |
log(`${label} ${msg}`); | |
} | |
public static dd(...args: any[]) { | |
dump(args); | |
process.exit(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment