Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shell): checks only the shell name and allows any argument #118

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -957,21 +958,21 @@ 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;
}
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;
Expand Down
12 changes: 7 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -29,22 +31,22 @@ 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;
}
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`
);
}
}
Expand Down
Loading