How to use the chalk.reset function in chalk

To help you get started, we’ve selected a few chalk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rap2hpoutre / taskz / index.js View on Github external
spinnies.update(id, { text: `${val}${counter}` });
  };
  if (t.tasks) {
    // Subtasks
    spinnies.update(id, {
      text: `β†’ ${t.text}${counter}`,
      status: "stopped"
    });
    await t.tasks.run(level + 1, ctx, spinnies);
  } else {
    // Run one task
    try {
      await t.task(ctx);
      spinnies.succeed(id, { text: chalk.reset(spinnies.pick(id).text) });
    } catch (e) {
      spinnies.fail(id, { text: chalk.reset(`${e.message}${counter}`) });
      if (t.stopOnError) {
        throw new Error("Stopped on error.");
      }
    }
  }
}
github mikermcneil / kit / bin / kit-deps.js View on Github external
var column1 = '';




              // Package name, installed version, & semver range
              // ========================================================================
              // Core deps
              if (depInfo.isCore) {
                if (depInfo.isInstalledVersionTrusted) {
                  // Installed version is a trusted release of a core dependency!
                  column1 += chalk.green('  ');
                  // column1 += chalk.green('βœ“ ');
                  if (depInfo.isCore) { column1 += chalk.reset(packageName); } else { column1 += chalk.reset(packageName); }
                  column1 += chalk.reset('@'+depInfo.installedVersion);
                }
                else {
                  // This is a core dep, but the installed version must not QUITE be valid (e.g. might be a prerelease)
                  // (In most cases, prereleases are in use on purpose anyway. So we wouldn't want to make this red & angry!)
                  column1 += chalk.dim('  ');
                  if (depInfo.isCore) { column1 += chalk.reset(packageName); } else { column1 += chalk.reset(packageName); }
                  column1 += chalk.reset('@'+depInfo.installedVersion);
                }
              }
              // Common deps
              else if (depInfo.isCommon) {
                if (depInfo.isInstalledVersionVerified) {
                  // Installed version is the verified/recommended one!
                  column1 += chalk.green('  ');
                  // column1 += chalk.green('βœ“ ');
github MarcusCemes / responsive-image-builder / src / Config.ts View on Github external
error.dataPath +
          '" must be one of: ' +
          // @ts-ignore Bad typings, unable to fix
          error.params.type
        );
      }
      return "> " + error.dataPath + " " + error.message + "\n";
    }, "");

    // Display the human-readable error in terminal
    const logger = new Logger();
    logger.error(
      "Could not start due to invalid config:\n" +
        reducedErrors +
        "\n" +
        chalk.reset('Refer to the README for acceptable configuration objects, or try "rib --help"')
    );

    throw new ConfigurationError(MAIN_ERRORS.configError, reducedErrors);
  }

  // Merge the config with the default
  return merge(defaultConfig, config);
}
github miscord / miscord / lib / logger.js View on Github external
log (logLevel, msg, obj, depth) {
    if (this.level < levels[logLevel]) return
    let prefix = ''
    if (typeof msg === 'object') {
      msg = chalk.reset() + this.inspect(msg, obj)
    } else if (obj) {
      prefix = chalk.reset(msg)
      msg = obj
        ? (typeof obj === 'string' ? '' : '\n') + this.inspect(obj, depth, 20 + prefix.length)
        : ''
    } else {
      msg = chalk.reset(msg)
    }
    msg = msg.split('\n').map(line =>
      [
        levelBadges[logLevel],
        chalk.gray(timezonedDate(d => d.split('T')[1])),
        this.getScopeForLevel(logLevel),
        levelArrows[logLevel],
        prefix,
        line
      ].join(' ')
    ).join('\n')
    console.log(msg)
  }
github JoshuaKGoldberg / TypeStat / src / initialization / index.ts View on Github external
export const initialization = async (logger: ProcessLogger): Promise => {
    logger.stdout.write(chalk.greenBright("πŸ‘‹"));
    logger.stdout.write(chalk.green(" Welcome to TypeStat! "));
    logger.stdout.write(chalk.greenBright("πŸ‘‹"));
    logger.stdout.write(chalk.reset(EOL));

    logger.stdout.write(chalk.reset(`This will create a new `));
    logger.stdout.write(chalk.yellowBright(fileName));
    logger.stdout.write(chalk.reset(` for you.${EOL}`));
    logger.stdout.write(`If you don't know how to answer, that's ok - just select the default answer.${EOL}`);
    logger.stdout.write(chalk.reset(EOL));

    try {
        await runPrompts();
    } catch (error) {
        logger.stderr.write(getQuickErrorSummary(error));
        return ResultStatus.ConfigurationError;
    }

    logger.stdout.write(chalk.reset(`${EOL}Awesome! You're now ready to:${EOL}`));
    logger.stdout.write(chalk.greenBright(`typestat --config ${fileName}`));
    logger.stdout.write(chalk.reset(`${EOL}${EOL}Once you run that, TypeStat will start auto-fixing your typings.${EOL}`));
    logger.stdout.write(chalk.yellow(`Please report any bugs on https://github.com/JoshuaKGoldberg/TypeStat! `));
github nfour / serverless-build-plugin / src / Logger.ts View on Github external
source ({ filePath }: { filePath: string }) {
    const basename = path.basename(filePath);

    return this.message(
      'SOURCE',
      c.grey(filePath.replace(basename, c.reset(basename))),
    );
  }
github shroudedcode / devstats / src / commands / show.ts View on Github external
function render() {
    let output = ''

    output += chalk`\n{blue   ${reportTitle}}\n`
    output += '\n'

    for (const account of accounts) {
      const {title, theme} = getAccountType(account)
      if (reports.has(account)) {
        const report = reports.get(account) as Report

        output += chalk`  {inverse ${theme(' ')}}`
        output += chalk`${chalk.reset(' ')}`
        output += chalk`${theme(title.padEnd(15))}`
        output += chalk`${renderReport(account, report)}\n`
      } else {
        output += chalk`  {gray.inverse  } {gray.dim ${title.padEnd(15)}}{dim Loading ...}\n`
      }
    }

    if (interactive) {
      output += '\n'

      const buttons = [
        chalk`{blue {dim [}{bold ←} ${reporter.previousLabel}{dim ]}}`,
        (index < 0 ? chalk.blue : chalk.gray)(chalk`{dim [}{bold β†’} ${reporter.nextLabel}{dim ]}`),
        chalk`{blue {dim [}{bold Q} Quit{dim ]}}`,
      ]
      output += buttons.join(' ')
github dylang / npm-check / lib / out / interactive-update.js View on Github external
function unselectable(options) {
    return new inquirer.Separator(chalk.reset(options ? options.title : ' '));
}
github JoshuaKGoldberg / TypeStat / src / initialization / index.ts View on Github external
logger.stdout.write(`If you don't know how to answer, that's ok - just select the default answer.${EOL}`);
    logger.stdout.write(chalk.reset(EOL));

    try {
        await runPrompts();
    } catch (error) {
        logger.stderr.write(getQuickErrorSummary(error));
        return ResultStatus.ConfigurationError;
    }

    logger.stdout.write(chalk.reset(`${EOL}Awesome! You're now ready to:${EOL}`));
    logger.stdout.write(chalk.greenBright(`typestat --config ${fileName}`));
    logger.stdout.write(chalk.reset(`${EOL}${EOL}Once you run that, TypeStat will start auto-fixing your typings.${EOL}`));
    logger.stdout.write(chalk.yellow(`Please report any bugs on https://github.com/JoshuaKGoldberg/TypeStat! `));
    logger.stdout.write(chalk.yellowBright("πŸ’–"));
    logger.stdout.write(chalk.reset(EOL));

    return ResultStatus.Succeeded;
};
github adriantanasa / github-wiki-sidebar / bin / github-wiki-sidebar.js View on Github external
const getDisplayList = () => {
        let listStr = filesOrder.reduce(reducer, '\n') + chalk.reset('\n---\n');
        return 'Change the priority/order of the items in menu'
        + chalk.reset(' ')
        + listStr;
    };