Skip to content

Commit

Permalink
test: Add condition for window to find eslint (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindavies8 committed May 8, 2022
1 parent 4093937 commit a45391c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/eslint-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const spawn = require('child_process').spawnSync;

const filesToCheck = '*.js';
const FORMAT_START = process.env.FORMAT_START || 'main';
const IS_WIN = process.platform === 'win32';
const ESLINT_PATH = IS_WIN ? 'node_modules\\.bin\\eslint.cmd' : 'node_modules/.bin/eslint';

function main (args) {
let fix = false;
Expand Down Expand Up @@ -44,10 +46,16 @@ function main (args) {
if (fix) {
options.push('--fix');
}
const result = spawn('node_modules/.bin/eslint', [...options], {

const result = spawn(ESLINT_PATH, [...options], {
encoding: 'utf-8'
});

if (result.error && result.error.errno === 'ENOENT') {
console.error('Eslint not found! Eslint is supposed to be found at ', ESLINT_PATH);
return 2;
}

if (result.status === 1) {
console.error('Eslint error:', result.stdout);
const fixCmd = 'npm run lint:fix';
Expand Down

0 comments on commit a45391c

Please sign in to comment.