Skip to content

Commit c7c7b58

Browse files
committed
fix: show “invalid command” error
- see: preactjs/preact-cli#813
1 parent 12c2926 commit c7c7b58

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Sade {
3838
usage = usage.join(' '); // to string
3939

4040
this.tree[cmd] = { usage, options:[], alias:{}, default:{}, examples:[] };
41-
desc && this.describe(desc);
41+
if (desc) this.describe(desc);
4242

4343
return this;
4444
}
@@ -112,8 +112,8 @@ class Sade {
112112
cmd = this.tree[name];
113113
arr.unshift(name);
114114
offset++;
115-
} else if (name) {
116-
return $.error(bin, `Invalid command: ${name}`);
115+
} else if (tmp) {
116+
return $.error(bin, `Invalid command: ${tmp}`);
117117
} //=> else: cmd not specified, wait for now...
118118
}
119119

test/usage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('(usage) basic :: error :: invalid command', t => {
3737
t.is(pid.status, 1, 'exits with error code');
3838
t.is(
3939
pid.stderr.toString(),
40-
'\n ERROR\n Invalid command: foobar.\n\n Run `$ bin --help` for more info.\n\n',
40+
'\n ERROR\n Invalid command: foobar\n\n Run `$ bin --help` for more info.\n\n',
4141
'~> stderr has "Invalid command: foobar" error message'
4242
);
4343
t.is(pid.stdout.length, 0, '~> stdout is empty');

0 commit comments

Comments
 (0)