From 40b6c65e5ebf9f79e183666ea8af818bd1a0bbd3 Mon Sep 17 00:00:00 2001 From: ureciocais Date: Mon, 25 Sep 2023 11:02:55 +0200 Subject: [PATCH] feat(shell): checks only the shell name and allows any argument --- dist/index.js | 11 ++++++----- src/index.ts | 12 +++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index c5029cb..f2bb3df 100644 --- a/dist/index.js +++ b/dist/index.js @@ -948,7 +948,8 @@ function getExecutable(inputs) { return OS === 'win32' ? 'powershell' : 'bash'; } var executable; - switch (inputs.shell) { + var shellName = inputs.shell.split(' ')[0]; + switch (shellName) { case 'bash': case 'python': case 'pwsh': { @@ -957,7 +958,7 @@ function getExecutable(inputs) { } case 'sh': { if (OS === 'win32') { - throw new Error("Shell ".concat(inputs.shell, " not allowed on OS ").concat(OS)); + throw new Error("Shell ".concat(shellName, " not allowed on OS ").concat(OS)); } executable = inputs.shell; break; @@ -965,13 +966,13 @@ function getExecutable(inputs) { case 'cmd': case 'powershell': { if (OS !== 'win32') { - throw new Error("Shell ".concat(inputs.shell, " not allowed on OS ").concat(OS)); + throw new Error("Shell ".concat(shellName, " not allowed on OS ").concat(OS)); } - executable = inputs.shell + '.exe'; + executable = shellName + '.exe' + inputs.shell.replace(shellName, ''); break; } default: { - throw new Error("Shell ".concat(inputs.shell, " not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells")); + throw new Error("Shell ".concat(shellName, " not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells")); } } return executable; diff --git a/src/index.ts b/src/index.ts index f443451..aa5642e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,7 +20,9 @@ function getExecutable(inputs: Inputs): string { } let executable: string; - switch (inputs.shell) { + const shellName = inputs.shell.split(' ')[0]; + + switch (shellName) { case 'bash': case 'python': case 'pwsh': { @@ -29,7 +31,7 @@ function getExecutable(inputs: Inputs): string { } case 'sh': { if (OS === 'win32') { - throw new Error(`Shell ${inputs.shell} not allowed on OS ${OS}`); + throw new Error(`Shell ${shellName} not allowed on OS ${OS}`); } executable = inputs.shell; break; @@ -37,14 +39,14 @@ function getExecutable(inputs: Inputs): string { case 'cmd': case 'powershell': { if (OS !== 'win32') { - throw new Error(`Shell ${inputs.shell} not allowed on OS ${OS}`); + throw new Error(`Shell ${shellName} not allowed on OS ${OS}`); } - executable = inputs.shell + '.exe'; + executable = shellName + '.exe' + inputs.shell.replace(shellName, ''); break; } default: { throw new Error( - `Shell ${inputs.shell} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells` + `Shell ${shellName} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells` ); } }