From 3761a22621705cb2dc11c95eeb71ac8fd05e3f44 Mon Sep 17 00:00:00 2001 From: stdlib-bot <noreply@stdlib.io> Date: Thu, 28 Mar 2024 23:16:39 +0000 Subject: [PATCH] Auto-generated commit --- lib/commands/rerun.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/commands/rerun.js b/lib/commands/rerun.js index 5636dd97..1cdc3f6a 100644 --- a/lib/commands/rerun.js +++ b/lib/commands/rerun.js @@ -67,21 +67,22 @@ function command( repl ) { return; } nargs = arguments.length; - if ( isString( arg ) ) { - FLG = 1; - } else if ( isNonNegativeInteger( arg ) ) { - FLG = 2; - } else if ( isRegExp( arg ) ) { - FLG = 3; - } else if ( isNonNegativeIntegerArray( arg ) ) { - FLG = 4; - } else { - err = new TypeError( format( 'invalid argument. Must provide a string, regular expression, nonnegative integer, or an array of nonnegative integers. Value: `%s`.', arg ) ); - debug( 'Error: %s', err.message ); - repl._ostream.write( 'Error: '+err.message+'\n' ); - return; + if ( nargs > 0 ) { + if ( isString( arg ) ) { + FLG = 1; + } else if ( isNonNegativeInteger( arg ) ) { + FLG = 2; + } else if ( isRegExp( arg ) ) { + FLG = 3; + } else if ( isNonNegativeIntegerArray( arg ) ) { + FLG = 4; + } else { + err = new TypeError( format( 'invalid argument. Must provide a string, regular expression, nonnegative integer, or an array of nonnegative integers. Value: `%s`.', arg ) ); + debug( 'Error: %s', err.message ); + repl._ostream.write( 'Error: '+err.message+'\n' ); + return; + } } - // 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... repl.once( 'drain', onFinish );