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


TypeScript colors.red函数代码示例

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


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

示例1: consoleTestResultHandler

export function consoleTestResultHandler(testResult: TestResult): boolean {
    let didAllTestsPass = true;

    for (const fileName of Object.keys(testResult.results)) {
        const results = testResult.results[fileName];
        process.stdout.write(`${fileName}:`);

        const diffResults = diff.diffLines(results.markupFromMarkup, results.markupFromLinter);
        const didTestPass = !diffResults.some((diff) => diff.added || diff.removed);

        /* tslint:disable:no-console */
        if (didTestPass) {
            console.log(colors.green(" Passed"));
        } else {
            console.log(colors.red(" Failed!"));
            console.log(colors.green(`Expected (from ${FILE_EXTENSION} file)`));
            console.log(colors.red("Actual (from TSLint)"));

            didAllTestsPass = false;

            for (const diffResult of diffResults) {
                let color = colors.grey;
                if (diffResult.added) {
                    color = colors.green;
                } else if (diffResult.removed) {
                    color = colors.red;
                }
                process.stdout.write(color(diffResult.value));
            }
        }
        /* tslint:enable:no-console */
    }

    return didAllTestsPass;
}
开发者ID:arnaudvalle,项目名称:tslint,代码行数:35,代码来源:test.ts

示例2:

process.on('unhandledRejection', (err: Error) => {
  if (err && err.message && err.stack) {
    console.error('\nAn unhandled rejection has occurred inside Forge:'.red);
    console.error(colors.red(err.message));
    console.error(colors.red(err.stack));
  } else {
    console.error('\nElectron forge was terminated:'.red);
    console.error(colors.red(typeof err === 'string' ? err : JSON.stringify(err)));
  }
  process.exit(1);
});
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:11,代码来源:terminate.ts

示例3: generate

    generate () {
        const self = this;
        const tasks: ReturnType<typeof writeFileCreateDir>[] = [];

        self.metadata.renderedFragments = {};

        // For each markdown, create the html fragment
        for (const mdTemplate in self.metadata.jsonml) {
            try {
                const tree = markdown.toHTMLTree(self.metadata.jsonml[mdTemplate]);
                const html = markdown.renderJsonML(tree);

                const outputFilename = self.generatorSettings.outputDir + '/' + mdTemplate + '.html';
                // mhmhmh TODO: This is sooo hardcoded
                self.metadata.renderedFragments[mdTemplate] = 'fragment/' + mdTemplate + '.html';

                tasks.push(writeFileCreateDir(outputFilename, html));

            } catch (e) {
                // TODO: Catch this better
                console.log(red('Problem with ') + mdTemplate);
                throw e;
            }
        }

        return Task.all(tasks);
    }
开发者ID:hrajchert,项目名称:mddoc,代码行数:27,代码来源:html-fragment-generator.ts

示例4: consoleTestResultHandler

export function consoleTestResultHandler(testResult: TestResult): boolean {
    let didAllTestsPass = true;

    for (const fileName of Object.keys(testResult.results)) {
        const results = testResult.results[fileName];
        process.stdout.write(`${fileName}:`);

        const markupDiffResults = diff.diffLines(results.markupFromMarkup, results.markupFromLinter);
        const fixesDiffResults = diff.diffLines(results.fixesFromLinter, results.fixesFromMarkup);
        const didMarkupTestPass = !markupDiffResults.some((diff) => !!diff.added || !!diff.removed);
        const didFixesTestPass = !fixesDiffResults.some((diff) => !!diff.added || !!diff.removed);

        /* tslint:disable:no-console */
        if (didMarkupTestPass && didFixesTestPass) {
            console.log(colors.green(" Passed"));
        } else {
            console.log(colors.red(" Failed!"));
            didAllTestsPass = false;
            if (!didMarkupTestPass) {
                displayDiffResults(markupDiffResults, MARKUP_FILE_EXTENSION);
            }
            if (!didFixesTestPass) {
                displayDiffResults(fixesDiffResults, FIXES_FILE_EXTENSION);
            }
        }
        /* tslint:enable:no-console */
    }

    return didAllTestsPass;
}
开发者ID:arusakov,项目名称:tslint,代码行数:30,代码来源:test.ts

示例5: async

    Coinjar: async () => {
        const rates = await rp({ uri: 'https://api.coinjar.com/v3/exchange_rates', json: true });
        const usd = parseFloat(rates.exchange_rates.BTCUSD.midpoint);
        const aud = parseFloat(rates.exchange_rates.BTCAUD.midpoint);

        return {
            usd: {
                raw: usd,
                formatted: colors.red(`$${usd.toFixed(2)}USD`)
            },
            aud: {
                raw: aud,
                formatted: colors.magenta(`$${aud.toFixed(2)}AUD`)
            },
            notifier: () => {
                function notify(operator, target, price) {
                    notifier.notify({
                        title: `CoinJar Midpoint ${operator} $${target}`,
                        sound: true,
                        message: price
                    });
        
                    player.play('Morning_Flower.mp3', function(err) {
                        //console.log(`Could not play sound! Error: ${err}`);
                    });
                }

                if (aud <= priceLow) {
                    notify('<=', priceLow, aud);
                } else if (aud >= priceHigh) {
                    notify('=>', priceHigh, aud); 
                } 
            }
        };
    },
开发者ID:khell,项目名称:scrape-coinjar,代码行数:35,代码来源:index.ts

示例6: leftLog

let check = (resultSet, subKey) => {
  depth++;
  // If there's no _meta, we need to recurse further
  if (!resultSet._meta) {
    leftLog(depth, '-', colors.underline.white(`${subKey}`));
    Object.keys(resultSet).forEach(key => check(resultSet[key], key));
    depth--;
    return;
  }
  // If there's no reference property, this was the first time we saw this key
  // So we need to check with the user to ensure that this is the right value
  if (!resultSet.hasOwnProperty('reference')) {
    leftLog(depth, colors.red(`X ${subKey}: No reference value found`));
    // Not using template functions here so we're not calling .toString on objects
    leftLog(depth + 1, colors.grey('Latest result:'), resultSet.current);
    if (keyInYNStrict('Use this value?')) {
      resultSet.reference = resultSet.current;
    }
  }

  // If there is a reference property (checked above) and no current, then the test passed
  // Move along, nothing to see here
  if (!resultSet.hasOwnProperty('current')) {
    leftLog(depth, `${greenCheckmark} ${subKey}`);
    depth--;
    return;
  }


  // If there are both current & reference properties, we need to ensure they match
  // If not, a test failed and the user probably wants to update the value there
  try {
    deepStrictEqual(resultSet.reference, resultSet.current);

    leftLog(depth, `${greenCheckmark} ${subKey}`);
  } catch (e) {
    leftLog(depth, colors.red(`X ${subKey}: Values don't match`));
    // Not using template functions here so we're not calling .toString on objects
    leftLog(depth + 1, colors.grey('Reference value:'), resultSet.reference);
    leftLog(depth + 1, colors.grey('Latest result:'), resultSet.current);
    if (keyInYNStrict('Should I replace this?')) {
      resultSet.reference = resultSet.current;
      delete resultSet.current;
    }
  }
  depth--;
};
开发者ID:SomeKittens,项目名称:baddsert,代码行数:47,代码来源:cli.ts

示例7: async

const main = async () => {
  try {
    await execCmd(`lerna publish --skip-git --skip-npm --yes --repo-version ${pckg.version}`);
  } catch (e) {
    console.error(colors.red(`Error : ${e.message}`));
    process.exit(1);
  }
};
开发者ID:santech-org,项目名称:ng-on-rest,代码行数:8,代码来源:upgrade.ts

示例8: removeItems

  _prompt.get(_promptSchemaLibraryName, (err: any, res: any) => {
    if (err) {
      console.log(colors.red("Sorry, there was an error building the workspace :("))
      removeItems()
      process.exit(1)
      return
    }

    setupLibrary(res.library)
  })
开发者ID:robertrbairdii,项目名称:typescript-library-starter,代码行数:10,代码来源:init.ts

示例9: async

const checkModulePublished = async (pckg: IPackage) => {
  try {
    const version = require(path.join(pckg.path, packageJson)).version;
    console.info(colors.green(`${pckg.name} version ${version}`));
    const versions: string[] = JSON.parse(await execCmd(`yarn info ${pckg.name} versions --json`)).data;
    return versions.indexOf(version) >= 0;
  } catch (e) {
    console.error(colors.red(`Error : ${e}`));
    return false;
  }
};
开发者ID:santech-org,项目名称:ng-on-rest,代码行数:11,代码来源:publish.ts


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