gpt4 book ai didi

gruntjs - 如果找不到文件,如何让 gruntjs 跳过 eslint 任务?

转载 作者:行者123 更新时间:2023-12-02 03:19:09 35 4
gpt4 key购买 nike

我正在使用带有 grunt-eslint 插件的 grunt。这是一个更大的 grunt 任务的一部分,该任务首先找到更改的文件并对它们执行各种任务。如果没有更改任何 JS 文件(例如,如果我只更改 CSS 文件),整个任务将中止,因为 eslint 失败并显示“找不到任何要验证的文件”消息。

$ grunt eslint:precommit
Running "eslint:precommit" (eslint) task
Could not find any files to validate.
Warning: Task "eslint:precommit" failed. Use --force to continue.

Aborted due to warnings.

如果没有找到任何 JS 文件,我不希望任务失败。

有没有办法:

一个。如果没有文件运行,grunt 任务是否甚至不调用 eslint 并且不会失败?

B.如果没有文件运行,eslint 不会失败吗?

(相关,但特定于从 grunt 调用的不同工具:Can an assemble target be silenced if there are no matching files? (Without using --force))

最佳答案

使用动态任务是您的解决方案,这里是文档的链接:http://gruntjs.com/frequently-asked-questions#dynamic-alias-tasks

相关链接:

关于gruntjs - 如果找不到文件,如何让 gruntjs 跳过 eslint 任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34638013/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com