Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

More nicer error handling #157

Merged
merged 1 commit into from

2 participants

@noway421

Nicer error handling when executing not existing command, or don't have permissions.
In fact, previous handling not works at all.

@tj tj merged commit 027b605 into tj:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 6, 2013
  1. @noway421

    More nicer error handling

    noway421 authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 index.js
View
11 index.js
@@ -405,14 +405,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);
}
});
};
Something went wrong with that request. Please try again.