当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chalk.reset函数代码示例

本文整理汇总了TypeScript中chalk.reset函数的典型用法代码示例。如果您正苦于以下问题:TypeScript reset函数的具体用法?TypeScript reset怎么用?TypeScript reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了reset函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: assertionErrorMessage

function assertionErrorMessage(
  error: AssertionErrorWithStack,
  options: DiffOptions,
) {
  const {expected, actual, generatedMessage, message, operator, stack} = error;
  const diffString = diff(expected, actual, options);
  const hasCustomMessage = !generatedMessage;
  const operatorName = getOperatorName(operator, stack);
  const trimmedStack = stack
    .replace(message, '')
    .replace(/AssertionError(.*)/g, '');

  if (operatorName === 'doesNotThrow') {
    return (
      assertThrowingMatcherHint(operatorName) +
      '\n\n' +
      chalk.reset(`Expected the function not to throw an error.\n`) +
      chalk.reset(`Instead, it threw:\n`) +
      `  ${printReceived(actual)}` +
      chalk.reset(hasCustomMessage ? '\n\nMessage:\n  ' + message : '') +
      trimmedStack
    );
  }

  if (operatorName === 'throws') {
    return (
      assertThrowingMatcherHint(operatorName) +
      '\n\n' +
      chalk.reset(`Expected the function to throw an error.\n`) +
      chalk.reset(`But it didn't throw anything.`) +
      chalk.reset(hasCustomMessage ? '\n\nMessage:\n  ' + message : '') +
      trimmedStack
    );
  }

  return (
    assertMatcherHint(operator, operatorName) +
    '\n\n' +
    chalk.reset(`Expected value ${operatorMessage(operator)}`) +
    `  ${printExpected(expected)}\n` +
    chalk.reset(`Received:\n`) +
    `  ${printReceived(actual)}` +
    chalk.reset(hasCustomMessage ? '\n\nMessage:\n  ' + message : '') +
    (diffString ? `\n\nDifference:\n\n${diffString}` : '') +
    trimmedStack
  );
}
开发者ID:Volune,项目名称:jest,代码行数:47,代码来源:assertionErrorMessage.ts

示例2: updateNotifier

    .then(it => {
      if (it.version === "0.0.0-semantic-release") {
        return
      }

      const notifier = updateNotifier({pkg: it})
      if (notifier.update != null) {
        notifier.notify({
          message: `Update available ${chalk.dim(notifier.update.current)}${chalk.reset(" → ")}${chalk.green(notifier.update.latest)} \nRun ${chalk.cyan("yarn upgrade electron-builder")} to update`
        })
      }
    })
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:12,代码来源:cli.ts

示例3: default

export default (testName: string, pattern: string, width: number) => {
  const inlineTestName = testName.replace(/(\r\n|\n|\r)/gm, ENTER);

  let regexp;

  try {
    regexp = new RegExp(pattern, 'i');
  } catch (e) {
    return chalk.dim(inlineTestName);
  }

  const match = inlineTestName.match(regexp);

  if (!match) {
    return chalk.dim(inlineTestName);
  }

  const startPatternIndex = Math.max(match.index || 0, 0);
  const endPatternIndex = startPatternIndex + match[0].length;

  if (inlineTestName.length <= width) {
    return colorize(inlineTestName, startPatternIndex, endPatternIndex);
  }

  const slicedTestName = inlineTestName.slice(0, width - DOTS.length);

  if (startPatternIndex < slicedTestName.length) {
    if (endPatternIndex > slicedTestName.length) {
      return colorize(
        slicedTestName + DOTS,
        startPatternIndex,
        slicedTestName.length + DOTS.length,
      );
    } else {
      return colorize(
        slicedTestName + DOTS,
        Math.min(startPatternIndex, slicedTestName.length),
        endPatternIndex,
      );
    }
  }

  return `${chalk.dim(slicedTestName)}${chalk.reset(DOTS)}`;
};
开发者ID:Volune,项目名称:jest,代码行数:44,代码来源:formatTestNameByPattern.ts

示例4:

 rcon.send(`${command} ${text || ""}`, response => {
   console.log(chalk.gray(`[Command Response] ${chalk.reset(response)}`))
 })
开发者ID:janispritzkau,项目名称:rcon,代码行数:3,代码来源:cli.ts

示例5: run


//.........这里部分代码省略.........
        this.cmd = await foundCommand.run(this.config)
        if (foundCommand.deprecated) {
          this.cmd.out.log(
            chalk.yellow(
              `\nThis command is deprecated and will be removed in 1.9`,
            ),
          )
        }
        this.setRavenUserContext()
        const checker = getStatusChecker()!
        checker.checkStatus(
          foundCommand.command ? id : id.split(':')[0],
          this.cmd.args,
          this.cmd.flags,
          this.cmd.argv,
        )

        if (process.env.NOCK_WRITE_RESPONSE_CLI === 'true') {
          const requests = require('nock').recorder.play()
          const requestsPath = path.join(process.cwd(), 'requests.js')
          debug('WRITING', requestsPath)
          fs.writeFileSync(requestsPath, requests.join('\n'))
        }
      } else {
        const topic = await dispatcher.findTopic(id)
        if (topic) {
          await this.Help.run(this.config)
          const checker = getStatusChecker()!
          checker.checkStatus(id, {}, {}, [])
        } else if (id === 'logs') {
          throw new CommandReplacedError('logs', 'cluster logs')
        } else if (id === 'push') {
          throw new CommandReplacedError('push', 'deploy')
        } else if (id === 'seed') {
          throw new CommandReplacedError('seed', 'import')
        } else if (
          [
            'cluster',
            'cluster:info',
            'cluster:add',
            'cluster:remove',
            'cluster:logs',
            'cluster:info',
          ].includes(id)
        ) {
          throw new CommandRemovedError(
            '1.7',
            'https://bit.ly/release-notes-1-7',
            '',
          )
        } else if (
          [
            'local',
            'local:up',
            'local:down',
            'local:start',
            'local:stop',
            'local:upgrade',
            'local:nuke',
            'local:ps',
          ].includes(id)
        ) {
          throw new CommandRemovedError(
            '1.7',
            'https://bit.ly/release-notes-1-7',
            'You can use docker-compose directly to manage the state of a local server.',
          )
        } else {
          return new NotFound(out, this.config.argv).run()
        }
      }
    }

    if (this.notifier.update) {
      this.notifier.notify({
        message:
          'Update available ' +
          chalk.dim(this.notifier.update.current) +
          chalk.reset(' → ') +
          chalk.cyan(this.notifier.update.latest) +
          `\nRun ${chalk.bold.cyan('npm i -g prisma')} to update`,
        boxenOpts: {
          padding: 1,
          margin: 1,
          align: 'center',
          borderColor: 'grey',
          borderStyle: 'round',
        },
      })
    }

    if (!this.config.argv.includes('playground')) {
      const { timeout } = require('./util')
      await timeout(this.flush(), 1000)

      out.exit(0)
    } else {
      debug('not flushing')
    }
  }
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:101,代码来源:CLI.ts

示例6: reset

 const r = (x: string) => colors ? reset(x) : x;
开发者ID:germanomarques,项目名称:angular-cli,代码行数:1,代码来源:stats.ts

示例7: run

async function run(coins: Coin[], options: Options) {
  const debug = Debug.create(options);
  debug("DEBUG ENABLED");
  debug("Arguments", process.argv);
  debug("Options", options);
  debug("Coins", coins);

  if (options.showHeader) {
    console.log("The results of this program do not necessarily reflect real world results and fees.");
    console.log("The market is constantly changing and what is profitable now might not be in a couple minutes.");
    console.log("Do your own research and don't spend what you can't afford to lose.");
    console.log("I am not responsible for any losses.");

    console.log("");
    console.log(chalk.reset(`BTC: ${chalk.underline("1GarboYPsadWuEi8B2Pv1SvwAsBHVn1ABZ")}`));
    console.log(chalk.reset(`LTC: ${chalk.underline("LfRV8T392L7M2n3pLk2DAus6bFhtqcfAht")}`));
    console.log(chalk.reset(`ETH: ${chalk.underline("0x86dd805eb129Bfb268F21455451cD3C4dAA1c5F9")}`));
    console.log("");
  }

  if (process.argv.length === 2) {
    console.log("Did you know that this script supports more coins than listed here?");
    console.log("Run this again like: `node index list` to see all supported coins. (there's lots!)");
    console.log("You can enable coins like so: `node index monero bitcoin litecoin`");
    console.log("");
  }

  // --fixed is buggy
  if (options.orderType === NHOrderType.Fixed) {
    var ul = chalk.underline("--fixed");
    console.warn(chalk.red(`${ul} is experimental and its results may not be accurate!`) + " Its use is discouraged!");
    console.warn(`Using an order speed of ${options.fixedSpeed}(any)H/s. The real price does increase and decrease with order size.`);
  }

  // get our api wrapper and load it
  var nicehash = new NiceHashAPI();
  try {
    await nicehash.getCoinCosts();
  } catch (e) {
    console.error(chalk.red(`Failed to load price data from NiceHash. Aborting.`));
    console.error(chalk.red("Error received:"));
    console.error(e);
    exit(1);
  }

  // remove disabled coins
  coins = coins.filter(coin => coin.enabled);

  console.log(`Using ${options.findMin ? "MINIMUM" : "AVERAGE"} prices.`);
  console.log("");

  for (var i = 0; i < coins.length; i++) {
    var coin = coins[i];

    // run the main logic
    // could maybe move into here because coin definitions no longer run on their own?
    await index(coin, options, nicehash);

    // do not wait after the last coin
    if (i + 1 < coins.length) {
      if (options.showPrompt) {
        await waitForInput();
      } else {
        await sleep(1000);
      }
    }

    console.log(""); // newline
  }
}
开发者ID:loadpm,项目名称:nicehash-calculator,代码行数:70,代码来源:index.ts

示例8: default

export default (str: string, start: number, end: number) =>
  chalk.dim(str.slice(0, start)) +
  chalk.reset(str.slice(start, end)) +
  chalk.dim(str.slice(end));
开发者ID:Volune,项目名称:jest,代码行数:4,代码来源:colorize.ts

示例9:

import * as fs from "fs-extra"
import * as chalk from "chalk"

console.log(chalk.underline("_"), chalk.reset("_"))

// Just some test scripts
let files = fs.readdirSync(__dirname)
files.forEach(str => {
  console.log(
    fs.statSync(str).isDirectory() ? chalk.cyan(str) :
    str[0] === '.' ? chalk.grey(str) :
    chalk.red(str)
  )
})

fs.writeFileSync("files.stats.json", JSON.stringify(files), "utf8")
开发者ID:ZombieHippie,项目名称:fantastic-repository,代码行数:16,代码来源:upload-artifacts.ts

示例10: dateFormat

const now = () => {
  const date = dateFormat(new Date(), '[dd/mm/yyyy hh:MM:ss]')
  return chalk.reset(date)
}
开发者ID:lolPants,项目名称:fancylog,代码行数:4,代码来源:construct.ts


注:本文中的chalk.reset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。