From ef18d05cf144efdaf8cae92640d3ef9c2958ab98 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Tue, 2 Mar 2021 10:05:18 -0600 Subject: [PATCH 1/2] Script files can now be used as step commands --- lib/command/shell.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/command/shell.js b/lib/command/shell.js index 46f814e..17285eb 100644 --- a/lib/command/shell.js +++ b/lib/command/shell.js @@ -21,6 +21,11 @@ function Command(params) { this.shellExtraArgs = params.shellExtraArgs || []; } + +function isScript(str){ + return (process.platform === 'win32' && str.endsWith('.bat')) || (process.platform !== 'win32' && str.endsWith('.sh')); +} + exports.Command = Command; inherits(Command, ParentCommand); @@ -33,7 +38,7 @@ inherits(Command, ParentCommand); Command.prototype.run = function(params, callback) { return ParentCommand.prototype.run.call(this, { cmd: this.shell, - args: this.shellExtraArgs.concat(this.shellCmdArg).concat(params.cmd), + args: isScript(params.cmd) ? this.shellExtraArgs.concat(params.cmd) : this.shellExtraArgs.concat(this.shellCmdArg).concat(params.cmd), options: params.options, envVars: params.envVars }, callback); From 571286d186ad334913745b2771f4dbc2b11eb7b1 Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Tue, 2 Mar 2021 10:55:05 -0600 Subject: [PATCH 2/2] Refactored long lines to be more jshint friendly --- lib/command/shell.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/command/shell.js b/lib/command/shell.js index 17285eb..0364098 100644 --- a/lib/command/shell.js +++ b/lib/command/shell.js @@ -21,9 +21,9 @@ function Command(params) { this.shellExtraArgs = params.shellExtraArgs || []; } - function isScript(str){ - return (process.platform === 'win32' && str.endsWith('.bat')) || (process.platform !== 'win32' && str.endsWith('.sh')); + return (process.platform === 'win32' && str.endsWith('.bat')) || + (process.platform !== 'win32' && str.endsWith('.sh')); } exports.Command = Command; @@ -38,7 +38,9 @@ inherits(Command, ParentCommand); Command.prototype.run = function(params, callback) { return ParentCommand.prototype.run.call(this, { cmd: this.shell, - args: isScript(params.cmd) ? this.shellExtraArgs.concat(params.cmd) : this.shellExtraArgs.concat(this.shellCmdArg).concat(params.cmd), + args: isScript(params.cmd) ? + this.shellExtraArgs.concat(params.cmd) : + this.shellExtraArgs.concat(this.shellCmdArg).concat(params.cmd), options: params.options, envVars: params.envVars }, callback);