-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
var proc = require('child_process'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
// This looks gross, but we don't want to fail if they don't have ESLint installed | ||
// locally. | ||
|
||
module.exports = function runESLint(details) { | ||
return new Promise(function(resolve) { | ||
var eslint = findESLintBinary(); | ||
if (eslint == null) { return; } | ||
proc.exec(eslint + ' ' + details.file + ' --fix', resolve); | ||
}); | ||
}; | ||
try { | ||
// eslint-disable-next-line node/no-unpublished-require | ||
var CLIEngine = require('eslint').CLIEngine; | ||
var engine = new CLIEngine({fix: true}); | ||
|
||
function findESLintBinary() { | ||
var possibleBinary = path.join(proc.execSync('npm bin').toString().trim(), 'eslint'); | ||
return fs.statSync(possibleBinary).isFile() ? possibleBinary : null; | ||
module.exports = function runESLint(details) { | ||
console.log(engine.executeOnText(details.source).results[0].output); | ||
}; | ||
} catch (err) { | ||
module.exports = function runESLint(details) { | ||
return details.source; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters