Skip to content

Commit 1139f99

Browse files
urecioureciocaisnick-fields
authored
feat(shell): checks only the shell name and allows any argument (#118)
Co-authored-by: ureciocais <[email protected]> Co-authored-by: Nick Fields <[email protected]>
1 parent 1d41e5d commit 1139f99

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

dist/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,8 @@ function getExecutable(inputs) {
948948
return OS === 'win32' ? 'powershell' : 'bash';
949949
}
950950
var executable;
951-
switch (inputs.shell) {
951+
var shellName = inputs.shell.split(' ')[0];
952+
switch (shellName) {
952953
case 'bash':
953954
case 'python':
954955
case 'pwsh': {
@@ -957,21 +958,21 @@ function getExecutable(inputs) {
957958
}
958959
case 'sh': {
959960
if (OS === 'win32') {
960-
throw new Error("Shell ".concat(inputs.shell, " not allowed on OS ").concat(OS));
961+
throw new Error("Shell ".concat(shellName, " not allowed on OS ").concat(OS));
961962
}
962963
executable = inputs.shell;
963964
break;
964965
}
965966
case 'cmd':
966967
case 'powershell': {
967968
if (OS !== 'win32') {
968-
throw new Error("Shell ".concat(inputs.shell, " not allowed on OS ").concat(OS));
969+
throw new Error("Shell ".concat(shellName, " not allowed on OS ").concat(OS));
969970
}
970-
executable = inputs.shell + '.exe';
971+
executable = shellName + '.exe' + inputs.shell.replace(shellName, '');
971972
break;
972973
}
973974
default: {
974-
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"));
975+
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"));
975976
}
976977
}
977978
return executable;

src/index.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ function getExecutable(inputs: Inputs): string {
2020
}
2121

2222
let executable: string;
23-
switch (inputs.shell) {
23+
const shellName = inputs.shell.split(' ')[0];
24+
25+
switch (shellName) {
2426
case 'bash':
2527
case 'python':
2628
case 'pwsh': {
@@ -29,22 +31,22 @@ function getExecutable(inputs: Inputs): string {
2931
}
3032
case 'sh': {
3133
if (OS === 'win32') {
32-
throw new Error(`Shell ${inputs.shell} not allowed on OS ${OS}`);
34+
throw new Error(`Shell ${shellName} not allowed on OS ${OS}`);
3335
}
3436
executable = inputs.shell;
3537
break;
3638
}
3739
case 'cmd':
3840
case 'powershell': {
3941
if (OS !== 'win32') {
40-
throw new Error(`Shell ${inputs.shell} not allowed on OS ${OS}`);
42+
throw new Error(`Shell ${shellName} not allowed on OS ${OS}`);
4143
}
42-
executable = inputs.shell + '.exe';
44+
executable = shellName + '.exe' + inputs.shell.replace(shellName, '');
4345
break;
4446
}
4547
default: {
4648
throw new Error(
47-
`Shell ${inputs.shell} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells`
49+
`Shell ${shellName} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells`
4850
);
4951
}
5052
}

0 commit comments

Comments
 (0)