在Windows上的npm脚本中使用通配符

我试图用npm脚本命令使用jshint来粘贴所有的javascript文件。

我在Windows上运行,无论我指定什么通配符,我似乎无法超过一个文件。

引用特定文件的作品:

"scripts": { "lint": "jshint app/main.js" } 

但是,以下所有结果都会导致错误:

 "scripts": { // results in Can't open app/**/*.js' "lint1": "jshint app/**/*.js", // results in Can't open app/*.js' "lint2": "jshint app/*.js", // results in Can't open app/**.js' "lint3": "jshint app/**.js", } 

尽pipe在Windows上使用npm作为脚本任务运行jshint时不能使用通配符,但是可以解决这个问题。 默认情况下,如果jshint传递一个目录,它将recursionsearch该目录。 所以在你的情况下,你可以简单地做:

 "script": { "lint": "jshint app" } 

甚至

 "script": { "lint": "jshint ." } 

这将导致所有文件(包括node_modules中的文件被删除) – 这可能不是你想要的。 最简单的方法是在项目的根目录下有一个名为.jshintignore的文件,其中包含您不想要的文件夹和脚本:

 node_modules/ build/ dir/another_unlinted_script.js 

这是一个跨平台的解决scheme,作为npm中的脚本任务jshint。