簡體   English   中英

如果沒有找到文件,如何讓gruntjs跳過eslint任務?

[英]How to have gruntjs skip eslint task if no files are found?

我正在使用grunt和grunt-eslint插件。 這是一個更大的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文件,我不希望任務失敗。

有沒有辦法:

A.如果沒有文件運行,那么grunt任務甚至不會調用eslint而不會失敗嗎?

B.如果沒有運行文件,有沒有失敗的問題?

(相關,但特定於從grunt調用的不同工具: 如果沒有匹配的文件,可以使匯編目標靜音嗎?(不使用--force)

使用動態任務是您的解決方案,這里是文檔的鏈接: http//gruntjs.com/frequently-asked-questions#dynamic-alias-tasks

相關鏈接:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM