Skip to content

Commit 81edd48

Browse files
committed
Fix error handling and update commands list
1 parent 672216e commit 81edd48

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

bin/cli

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,22 @@ function main() {
7474
args = cli.args();
7575

7676
// Extract the command:
77-
cmd = args[ 0 ];
78-
if ( cmd === 'help' ) {
77+
if ( args[ 0 ] === 'help' ) {
7978
if ( args[ 1 ] === void 0 ) {
8079
return cli.help();
8180
}
8281
cmd = COMMANDS[ args[ 1 ] ];
8382
if ( cmd === void 0 ) {
84-
return onError( new Error( 'invalid argument. Unrecognized/unsupported command. Value: `' + cmd + '`.' ) );
83+
return onError( new Error( 'invalid argument. Unrecognized/unsupported command. Value: `' + args[ 1 ] + '`.' ) );
8584
}
86-
cmd = resolve( __dirname, '..', cmd );
85+
cmd = resolve( __dirname, '..', cmd.path );
8786
subargs = [ cmd, '--help' ];
8887
} else {
89-
cmd = COMMANDS[ cmd ];
88+
cmd = COMMANDS[ args[ 0 ] ];
9089
if ( cmd === void 0 ) {
91-
return onError( new Error( 'invalid argument. Unrecognized/unsupported command. Value: `' + cmd + '`.' ) );
90+
return onError( new Error( 'invalid argument. Unrecognized/unsupported command. Value: `' + args[ 0 ] + '`.' ) );
9291
}
93-
cmd = resolve( __dirname, '..', cmd );
92+
cmd = resolve( __dirname, '..', cmd.path );
9493
subargs = [ cmd ];
9594
for ( i = 1; i < args.length; i++ ) {
9695
subargs.push( args[ i ] );

bin/commands.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
2-
"datasets": "./lib/node_modules/@stdlib/datasets/bin/cli",
3-
"ls": "./lib/node_modules/@stdlib/_tools/pkgs/names/bin/cli",
4-
"ls-tree": "./lib/node_modules/@stdlib/_tools/pkgs/tree/bin/cli",
5-
"ns": "./lib/node_modules/@stdlib/namespace/bin/cli",
6-
"repl": "./lib/node_modules/@stdlib/repl/bin/cli"
2+
"datasets": {
3+
"path": "./lib/node_modules/@stdlib/datasets/bin/cli"
4+
},
5+
"ls": {
6+
"path": "./lib/node_modules/@stdlib/_tools/pkgs/names/bin/cli"
7+
},
8+
"ls-tree": {
9+
"path": "./lib/node_modules/@stdlib/_tools/pkgs/tree/bin/cli"
10+
},
11+
"ns": {
12+
"path": "./lib/node_modules/@stdlib/namespace/bin/cli"
13+
},
14+
"repl": {
15+
"path": "./lib/node_modules/@stdlib/repl/bin/cli"
16+
}
717
}

0 commit comments

Comments
 (0)