Skip to content

Commit

Permalink
Merge pull request #84 from codeclimate/will/fix-eslintignore-behavior
Browse files Browse the repository at this point in the history
Keep paths relative to /code
  • Loading branch information
wfleming committed Mar 15, 2016
2 parents b6a4060 + b6f95c2 commit 3bca438
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions bin/eslint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/src/app/bin/node_gc

process.chdir('/code');
var CODE_DIR = "/code";
process.chdir(CODE_DIR);

// Redirect `console.log` so that we are the only ones
// writing to STDOUT
Expand Down Expand Up @@ -79,10 +80,9 @@ function isFileWithMatchingExtension(file, extensions) {
}

function isFileIgnoredByLibrary(file) {
var path = file.replace(/^\/code\//, "");
var ignored = cli.isPathIgnored(path);
var ignored = cli.isPathIgnored(file);
if (ignored) {
var output = "File `" + path + "` ignored because of your .eslintignore file." + "\n";
var output = "File `" + file + "` ignored because of your .eslintignore file." + "\n";
process.stderr.write(output);
}
return ignored;
Expand Down Expand Up @@ -115,18 +115,16 @@ function inclusionBasedFileListBuilder(includePaths) {
if ((/\/$/).test(fileOrDirectory)) {
// if it ends in a slash, expand and push
var filesInThisDirectory = glob.sync(
"/code/" + fileOrDirectory + "/**/**"
fileOrDirectory + "/**/**"
);
prunePathsWithinSymlinks(filesInThisDirectory).forEach(function(file, j){
if (!isFileIgnoredByLibrary(file) && isFileWithMatchingExtension(file, extensions)) {
analysisFiles.push(file);
}
});
} else {
// if not, check for ending in *.js
var fullPath = "/code/" + fileOrDirectory;
if (!isFileIgnoredByLibrary(fullPath) && isFileWithMatchingExtension(fullPath, extensions)) {
analysisFiles.push(fullPath);
if (!isFileIgnoredByLibrary(fileOrDirectory) && isFileWithMatchingExtension(fileOrDirectory, extensions)) {
analysisFiles.push(fileOrDirectory);
}
}
});
Expand All @@ -151,7 +149,7 @@ runWithTiming("engineConfig", function () {

var userConfig = engineConfig.config || {};
if (userConfig.config) {
options.configFile = "/code/" + userConfig.config;
options.configFile = CODE_DIR + "/" + userConfig.config;
}

if (userConfig.extensions) {
Expand Down

0 comments on commit 3bca438

Please sign in to comment.