Skip to content

Commit 33e4029

Browse files
authored
test: Add condition for window to find eslint (#1176)
1 parent d53843b commit 33e4029

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/eslint-format.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const spawn = require('child_process').spawnSync;
44

55
const filesToCheck = '*.js';
66
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';
79

810
function main (args) {
911
let fix = false;
@@ -44,10 +46,16 @@ function main (args) {
4446
if (fix) {
4547
options.push('--fix');
4648
}
47-
const result = spawn('node_modules/.bin/eslint', [...options], {
49+
50+
const result = spawn(ESLINT_PATH, [...options], {
4851
encoding: 'utf-8'
4952
});
5053

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+
5159
if (result.status === 1) {
5260
console.error('Eslint error:', result.stdout);
5361
const fixCmd = 'npm run lint:fix';

0 commit comments

Comments
 (0)