Permalink
Browse files

Merge pull request #157 from noway421/patch-2

More nicer error handling
  • Loading branch information...
2 parents 9766406 + 82c3cbe commit 027b605c461bad4d78ae8b8017c56a230862baef @tj committed Jul 9, 2013
Showing with 6 additions and 5 deletions.
  1. +6 −5 index.js
View
@@ -407,14 +407,15 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
// check for ./<bin> first
var local = path.join(dir, bin);
- if (exists(local)) bin = local;
// run it
args = args.slice(1);
- var proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
- proc.on('exit', function(code){
- if (code == 127) {
- console.error('\n %s(1) does not exist\n', bin);
+ var proc = spawn(local, args, { stdio: 'inherit', customFds: [0, 1, 2] });
+ proc.on('error', function(err){
+ if (err.code == "ENOENT") {
+ console.error('\n %s(1) does not exist, try --help\n', bin);
+ } else if (err.code == "EACCES") {
+ console.error('\n %s(1) not executable. try chmod or run with root\n', bin);
}
});
};

0 comments on commit 027b605

Please sign in to comment.