Skip to content

Commit

Permalink
Add an 'errno' property to the Error object in callbacks, and set it …
Browse files Browse the repository at this point in the history
…to 'process.ENOENT' when a "Path 'path' does not exist in 'commit-ref'" error occurs.
  • Loading branch information
TooTallNate authored and creationix committed Sep 22, 2010
1 parent b85727e commit af8bcf7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/git-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var CACHE_LIFE = [36300000, 100];

var gitCommands, gitDir, workTree;

var gitENOENT = /fatal: Path '([^']+)' does not exist in '([0-9a-f]{40})'/;

// Set up the git configs for the subprocess
var Git = module.exports = function (repo) {
// Check the directory exists first.
Expand Down Expand Up @@ -173,7 +175,11 @@ function gitExec(commands, callback) {
});
child.addListener('exit', function (code) {
if (code > 0) {
callback(new Error("git " + commands.join(" ") + "\n" + stderr.join('')));
var err = new Error("git " + commands.join(" ") + "\n" + stderr.join(''));
if (gitENOENT.test(err.message)) {
err.errno = process.ENOENT;
}
callback(err);
return;
}
callback(null, stdout.join(''));
Expand Down

0 comments on commit af8bcf7

Please sign in to comment.