Skip to content

Commit

Permalink
Fix: Ensure piped in code will trigger correct errors (fixes #2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Mar 27, 2015
1 parent 0653cf7 commit 1fe6660
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion bin/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ var exitCode = 0,

if (useStdIn) {
process.stdin.pipe(concat({ encoding: "string" }, function(text) {
exitCode = cli.execute(process.argv, text);
try {
exitCode = cli.execute(process.argv, text);
} catch (ex) {
console.error(ex.message);
exitCode = 1;
}
}));
} else {
exitCode = cli.execute(process.argv);
Expand Down
4 changes: 3 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function loadConfig(filePath) {
try {
config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, "utf8"))) || {};
} catch (e) {
debug("Error reading YAML file: " + filePath);
e.message = "Cannot read config file: " + filePath + "\nError: " + e.message;
throw e;
}
Expand Down Expand Up @@ -136,6 +137,7 @@ function getLocalConfig(thisConfig, directory) {
numFiles = localConfigFiles.length;

for (i = 0; i < numFiles; i++) {

localConfigFile = localConfigFiles[i];
localConfig = loadConfig(localConfigFile);

Expand Down Expand Up @@ -259,7 +261,7 @@ Config.prototype.getConfig = function (filePath) {
directory = filePath ? path.dirname(filePath) : process.cwd(),
pluginConfig;

debug("Constructing config for " + filePath);
debug("Constructing config for " + (filePath ? filePath : "text"));

config = this.cache[directory];

Expand Down

0 comments on commit 1fe6660

Please sign in to comment.