feat: parse quotation in args input

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
This commit is contained in:
Alfi Maulana 2024-11-20 23:06:17 +07:00
parent a3faf400e7
commit a2e5d22b54
No known key found for this signature in database
GPG Key ID: 2242A64C2A8DF5A4
3 changed files with 6 additions and 10 deletions

4
dist/action.mjs generated vendored
View File

@ -382,9 +382,7 @@ function getContext() {
configure: {
generator: getInput("generator"),
options,
args: getInput("args")
.split(/\s+/)
.filter((arg) => arg != ""),
args: shellQuoteExports.parse(getInput("args")).map((arg) => arg.toString()),
},
build: {
enabled: getInput("run-build") == "true",

View File

@ -116,12 +116,12 @@ describe("get action context", () => {
},
{
name: "with additional arguments specified",
inputs: { args: "-Wdev -Wdeprecated\n--fresh" },
inputs: { args: `-Wdev -Wdeprecated\n--fresh --foo "bar baz"` },
expectedContext: {
configure: {
generator: "",
options: [],
args: ["-Wdev", "-Wdeprecated", "--fresh"],
args: ["-Wdev", "-Wdeprecated", "--fresh", "--foo", "bar baz"],
},
},
},
@ -151,7 +151,7 @@ describe("get action context", () => {
"c-flags": "-Werror -Wall\n-Wextra",
"cxx-flags": "-Werror -Wall\n-Wextra -Wpedantic",
options: `BUILD_TESTING=ON BUILD_EXAMPLES=ON\nBUILD_DOCS=ON FOO="BAR BAZ"`,
args: "-Wdev -Wdeprecated\n--fresh",
args: `-Wdev -Wdeprecated\n--fresh --foo "bar baz"`,
"run-build": "true",
"build-args": "--target foo\n--parallel 8",
},
@ -170,7 +170,7 @@ describe("get action context", () => {
"BUILD_DOCS=ON",
"FOO=BAR BAZ",
],
args: ["-Wdev", "-Wdeprecated", "--fresh"],
args: ["-Wdev", "-Wdeprecated", "--fresh", "--foo", "bar baz"],
},
build: {
enabled: true,

View File

@ -49,9 +49,7 @@ export function getContext(): Context {
configure: {
generator: getInput("generator"),
options,
args: getInput("args")
.split(/\s+/)
.filter((arg) => arg != ""),
args: parse(getInput("args")).map((arg) => arg.toString()),
},
build: {
enabled: getInput("run-build") == "true",