• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript chalk.greenColor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

                messages.map(function(message) {
                    let messageType;
                    // fixable
                    const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
                    if (message.fix) {
                        totalFixable++;
                    }
                    if ((message as any).fatal || message.severity === 2) {
                        messageType = fixableIcon + chalk.red("error");
                        summaryColor = "red";
                        errors++;
                    } else {
                        messageType = fixableIcon + chalk.yellow("warning");
                        warnings++;
                    }

                    return [
                        "",
                        message.line || 0,
                        message.column || 0,
                        messageType,
                        message.message.replace(/\.$/, ""),
                        chalk.gray(message.ruleId || "")
                    ];
                }),
开发者ID:textlint,项目名称:textlint,代码行数:25,代码来源:stylish.ts


示例2:

            messages.map(function(message) {
                // fixable
                totalFixed++;
                const messageType = chalk[greenColor].bold("\u2714 ");

                return [
                    "",
                    message.line || 0,
                    message.column || 0,
                    messageType,
                    message.message.replace(/\.$/, ""),
                    chalk.gray(message.ruleId || "")
                ];
            }),
开发者ID:textlint,项目名称:textlint,代码行数:14,代码来源:stylish.ts


示例3: prettyError

 messages.forEach(function(message) {
     // fixable
     const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
     if (message.fix) {
         totalFixable++;
     }
     if ((message as any).fatal || message.severity === 2) {
         errors++;
     } else {
         warnings++;
     }
     const r = fixableIcon + prettyError(code, result.filePath, message);
     if (r) {
         output += r + "\n";
     }
 });
开发者ID:textlint,项目名称:textlint,代码行数:16,代码来源:pretty-error.ts


示例4: formatter

function formatter(results: TextlintResult[]) {
    let output = "\n";
    let total = 0;
    let totalFixable = 0;
    let errors = 0;
    let warnings = 0;
    let summaryColor = "yellow";
    let greenColor = "green";

    results.forEach(function(result) {
        const messages = result.messages;

        if (messages.length === 0) {
            return;
        }

        total += messages.length;
        output += chalk.underline(result.filePath) + "\n";

        output +=
            table(
                messages.map(function(message) {
                    let messageType;
                    // fixable
                    const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
                    if (message.fix) {
                        totalFixable++;
                    }
                    if ((message as any).fatal || message.severity === 2) {
                        messageType = fixableIcon + chalk.red("error");
                        summaryColor = "red";
                        errors++;
                    } else {
                        messageType = fixableIcon + chalk.yellow("warning");
                        warnings++;
                    }

                    return [
                        "",
                        message.line || 0,
                        message.column || 0,
                        messageType,
                        message.message.replace(/\.$/, ""),
                        chalk.gray(message.ruleId || "")
                    ];
                }),
                {
                    align: ["", "r", "l"],
                    stringLength: function(str: string) {
                        const lines = chalk.stripColor(str).split("\n");
                        return Math.max.apply(
                            null,
                            lines.map(function(line: string) {
                                return widthOfString(line);
                            })
                        );
                    }
                }
            )
                .split("\n")
                .map(function(el: string) {
                    return el.replace(/(\d+)\s+(\d+)/, function(_, p1, p2) {
                        return chalk.gray(p1 + ":" + p2);
                    });
                })
                .join("\n") + "\n\n";
    });

    if (total > 0) {
        output += chalk[summaryColor].bold(
            [
                "\u2716 ",
                total,
                pluralize(" problem", total),
                " (",
                errors,
                pluralize(" error", errors),
                ", ",
                warnings,
                pluralize(" warning", warnings),
                ")\n"
            ].join("")
        );
    }

    if (totalFixable > 0) {
        output += chalk[greenColor].bold(
            "✓ " + totalFixable + " fixable " + pluralize("problem", totalFixable) + ".\n"
        );
        output += "Try to run: $ " + chalk.underline("textlint --fix [file]") + "\n";
    }

    return total > 0 ? output : "";
}
开发者ID:textlint,项目名称:textlint,代码行数:94,代码来源:stylish.ts


示例5: function

export default function(results: TextlintFixResult[], options: any) {
    // default: true
    chalk.enabled = options.color !== undefined ? options.color : true;
    let output = "\n";
    let totalFixed = 0;
    let errors = 0;
    const summaryColor = "yellow";
    const greenColor = "green";

    results.forEach(function(result) {
        const filePath = result.filePath;
        const messages = result.applyingMessages;
        // still error count
        const remainingMessages = result.remainingMessages;
        errors += remainingMessages.length;
        totalFixed += messages.length;
        if (messages.length === 0) {
            return;
        }
        if (!isFile(filePath)) {
            return;
        }
        output += `${chalk.underline(result.filePath)}\n`;

        const originalContent = fs.readFileSync(filePath, "utf-8");
        const diff = jsdiff.diffLines(originalContent, result.output);

        diff.forEach(function(part: any, index: number) {
            const prevLine = diff[index - 1];
            const nextLine = diff[index + 1];
            if (!isModified(part) && part.count > 1) {
                const greyColor = "grey";
                /*
                    <MODIFIED>
                    first line
                    ....
                 */
                if (isModified(prevLine)) {
                    const lines = part.value.split("\n");
                    output += `${chalk[greyColor](lines[0])}\n`;
                }
                output += chalk[greyColor]("...");
                if (isModified(nextLine)) {
                    const lines = part.value.split("\n");
                    output += `${chalk[greyColor](lines[lines.length - 1])}\n`;
                }
                /*
                    ...
                    last line
                    <MODIFIED>
                 */
                return;
            }
            // green for additions, red for deletions
            // grey for common parts
            let lineColor;
            let diffMark = "";
            if (part.added) {
                lineColor = "green";
                diffMark = "+ ";
            } else if (part.removed) {
                lineColor = "red";
                diffMark = "- ";
            } else {
                lineColor = "grey";
                diffMark = "";
            }
            output += chalk[lineColor](addMarkEachLine(diffMark, part.value));
        });
        output += "\n\n";
    });

    if (totalFixed > 0) {
        output += chalk[greenColor].bold(
            [
                // http://www.fileformat.info/info/unicode/char/2714/index.htm
                "✔ Fixed ",
                totalFixed,
                pluralize(" problem", totalFixed),
                "\n"
            ].join("")
        );
    }

    if (errors > 0) {
        output += chalk[summaryColor].bold(
            [
                // http://www.fileformat.info/info/unicode/char/2716/index.htm
                "✖ Remaining ",
                errors,
                pluralize(" problem", errors),
                "\n"
            ].join("")
        );
    }

    return totalFixed > 0 ? output : "";
}
开发者ID:textlint,项目名称:textlint,代码行数:98,代码来源:diff.ts


示例6: function

export default function(results: TextlintFixResult[], options: any) {
    // default: true
    chalk.enabled = options.color !== undefined ? options.color : true;
    let output = "\n";
    let totalFixed = 0;
    let errors = 0;
    const summaryColor = "yellow";
    const greenColor = "green";

    results.forEach(function(result) {
        if (!result.applyingMessages || !result.remainingMessages) {
            return;
        }
        const messages = result.applyingMessages;
        // still error count
        const remainingMessages = result.remainingMessages;
        errors += remainingMessages.length;
        if (messages.length === 0) {
            return;
        }
        output += `${chalk.underline(result.filePath)}\n`;

        output += `${table(
            messages.map(function(message) {
                // fixable
                totalFixed++;
                const messageType = chalk[greenColor].bold("\u2714 ");

                return [
                    "",
                    message.line || 0,
                    message.column || 0,
                    messageType,
                    message.message.replace(/\.$/, ""),
                    chalk.gray(message.ruleId || "")
                ];
            }),
            {
                align: ["", "r", "l"],
                stringLength: (str: string) => {
                    const lines = chalk.stripColor(str).split("\n");
                    return Math.max.apply(
                        null,
                        lines.map(function(line: string) {
                            return widthOfString(line);
                        })
                    );
                }
            }
        )
            .split("\n")
            .map(function(el: string) {
                return el.replace(/(\d+)\s+(\d+)/, function(_m, p1, p2) {
                    return chalk.gray(`${p1}:${p2}`);
                });
            })
            .join("\n")}\n\n`;
    });

    if (totalFixed > 0) {
        output += chalk[greenColor].bold(
            [
                // http://www.fileformat.info/info/unicode/char/2714/index.htm
                "\u2714 Fixed ",
                totalFixed,
                pluralize(" problem", totalFixed),
                "\n"
            ].join("")
        );
    }

    if (errors > 0) {
        output += chalk[summaryColor].bold(
            [
                // http://www.fileformat.info/info/unicode/char/2716/index.htm
                "\u2716 Remaining ",
                errors,
                pluralize(" problem", errors),
                "\n"
            ].join("")
        );
    }

    return totalFixed > 0 ? output : "";
}
开发者ID:textlint,项目名称:textlint,代码行数:85,代码来源:stylish.ts


示例7: formatter

/**
 *
 * @param {TextLintResult[]} results
 * @param {TextLintFormatterOption} options
 * @returns {string}
 */
function formatter(results: TextlintResult[], options: TextLintFormatterOption) {
    // default: true
    const useColor = options.color !== undefined ? options.color : true;
    let output = "";
    let total = 0;
    let errors = 0;
    let warnings = 0;
    let totalFixable = 0;
    results.forEach(function(result) {
        const code = require("fs").readFileSync(result.filePath, "utf-8");
        const messages = result.messages;
        if (messages.length === 0) {
            return;
        }
        total += messages.length;
        messages.forEach(function(message) {
            // fixable
            const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
            if (message.fix) {
                totalFixable++;
            }
            if ((message as any).fatal || message.severity === 2) {
                errors++;
            } else {
                warnings++;
            }
            const r = fixableIcon + prettyError(code, result.filePath, message);
            if (r) {
                output += r + "\n";
            }
        });
    });

    if (total > 0) {
        output += chalk[summaryColor].bold(
            [
                "\u2716 ",
                total,
                pluralize(" problem", total),
                " (",
                errors,
                pluralize(" error", errors),
                ", ",
                warnings,
                pluralize(" warning", warnings),
                ")\n"
            ].join("")
        );
    }

    if (totalFixable > 0) {
        output += chalk[greenColor].bold(
            "✓ " + totalFixable + " fixable " + pluralize("problem", totalFixable) + ".\n"
        );
        output += "Try to run: $ " + chalk.underline("textlint --fix [file]") + "\n";
    }

    if (!useColor) {
        return stripAnsi(output);
    }
    return output;
}
开发者ID:textlint,项目名称:textlint,代码行数:68,代码来源:pretty-error.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript chalk.red类代码示例发布时间:2022-05-24
下一篇:
TypeScript chalk.green类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap