Using wildcards in npm scripts in windows

I am trying to use all my javascript files using jshint with the npm script command.

I run windows and no matter what template I specify, I cannot submit multiple files.

Link to a specific file works:

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

But all of the following errors:

 "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", } 
+7
javascript npm
source share
1 answer

Although you cannot use wildcards when running jshint as a script task in npm on windows, you can get around this. By default, if jshint is passed to a directory, it will look for that directory recursively. Therefore, in your case, you can simply:

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

or even

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

This will cause all files, including those that are in node_modules, to be unrated - this is probably not what you want. The easiest way to get around this is to have a file called .jshintignore in the root directory of your project containing folders and scripts that you do not want to use:

 node_modules/ build/ dir/another_unlinted_script.js 

This is a cross-platform solution for jshint as a script task in npm.

+19
source share

All Articles