Skip to content

Commit 73268b2

Browse files
committed
fix: only perform argument validation if provided an argument
1 parent 8204e8b commit 73268b2

File tree

1 file changed

+15
-14
lines changed
  • lib/node_modules/@stdlib/repl/lib/commands

1 file changed

+15
-14
lines changed

lib/node_modules/@stdlib/repl/lib/commands/rerun.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,22 @@ function command( repl ) {
6767
return;
6868
}
6969
nargs = arguments.length;
70-
if ( isString( arg ) ) {
71-
FLG = 1;
72-
} else if ( isNonNegativeInteger( arg ) ) {
73-
FLG = 2;
74-
} else if ( isRegExp( arg ) ) {
75-
FLG = 3;
76-
} else if ( isNonNegativeIntegerArray( arg ) ) {
77-
FLG = 4;
78-
} else {
79-
err = new TypeError( format( 'invalid argument. Must provide a string, regular expression, nonnegative integer, or an array of nonnegative integers. Value: `%s`.', arg ) );
80-
debug( 'Error: %s', err.message );
81-
repl._ostream.write( 'Error: '+err.message+'\n' );
82-
return;
70+
if ( nargs > 0 ) {
71+
if ( isString( arg ) ) {
72+
FLG = 1;
73+
} else if ( isNonNegativeInteger( arg ) ) {
74+
FLG = 2;
75+
} else if ( isRegExp( arg ) ) {
76+
FLG = 3;
77+
} else if ( isNonNegativeIntegerArray( arg ) ) {
78+
FLG = 4;
79+
} else {
80+
err = new TypeError( format( 'invalid argument. Must provide a string, regular expression, nonnegative integer, or an array of nonnegative integers. Value: `%s`.', arg ) );
81+
debug( 'Error: %s', err.message );
82+
repl._ostream.write( 'Error: '+err.message+'\n' );
83+
return;
84+
}
8385
}
84-
8586
// Why defer? In order to allow the `rerun()` command to finish before actually evaluating the commands to rerun, thus ensuring that commands are run as if a user manually enters them...
8687
repl.once( 'drain', onFinish );
8788

0 commit comments

Comments
 (0)