File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ const spawn = require('child_process').spawnSync;
4
4
5
5
const filesToCheck = '*.js' ;
6
6
const FORMAT_START = process . env . FORMAT_START || 'main' ;
7
+ const IS_WIN = process . platform === 'win32' ;
8
+ const ESLINT_PATH = IS_WIN ? 'node_modules\\.bin\\eslint.cmd' : 'node_modules/.bin/eslint' ;
7
9
8
10
function main ( args ) {
9
11
let fix = false ;
@@ -44,10 +46,16 @@ function main (args) {
44
46
if ( fix ) {
45
47
options . push ( '--fix' ) ;
46
48
}
47
- const result = spawn ( 'node_modules/.bin/eslint' , [ ...options ] , {
49
+
50
+ const result = spawn ( ESLINT_PATH , [ ...options ] , {
48
51
encoding : 'utf-8'
49
52
} ) ;
50
53
54
+ if ( result . error && result . error . errno === 'ENOENT' ) {
55
+ console . error ( 'Eslint not found! Eslint is supposed to be found at ' , ESLINT_PATH ) ;
56
+ return 2 ;
57
+ }
58
+
51
59
if ( result . status === 1 ) {
52
60
console . error ( 'Eslint error:' , result . stdout ) ;
53
61
const fixCmd = 'npm run lint:fix' ;
You can’t perform that action at this time.
0 commit comments