kim*_*gro 8 javascript node.js npm
我试图使用jshint和npm脚本命令来lint我的所有javascript文件.
我在Windows上运行,无论我指定哪个通配符,我似乎都不能lint多个文件.
引用特定文件有效:
"scripts": {
"lint": "jshint app/main.js"
}
Run Code Online (Sandbox Code Playgroud)
但以下所有结果都会导致错误:
"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",
}
Run Code Online (Sandbox Code Playgroud)
Ric*_*ams 20
虽然在Windows上的npm中将jshint作为脚本任务运行时无法使用通配符,但您可以解决它.默认情况下,如果jshint传递给目录,它将以递归方式搜索该目录.所以在你的情况下,你可以简单地做:
"script": {
"lint": "jshint app"
}
Run Code Online (Sandbox Code Playgroud)
甚至
"script": {
"lint": "jshint ."
}
Run Code Online (Sandbox Code Playgroud)
这将导致所有文件 - 包括node_modules中的文件被删除 - 这可能不是您想要的.最简单的方法是.jshintignore在项目的根目录中调用一个包含您不想要的文件夹和脚本的文件:
node_modules/
build/
dir/another_unlinted_script.js
Run Code Online (Sandbox Code Playgroud)
这是jshint作为npm脚本任务的跨平台解决方案.
| 归档时间: |
|
| 查看次数: |
2905 次 |
| 最近记录: |