feat: parse quotation in build-args input

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
This commit is contained in:
Alfi Maulana 2024-11-20 23:08:30 +07:00
parent a2e5d22b54
commit bc6eb9d372
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

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

View File

@ -132,11 +132,11 @@ describe("get action context", () => {
}, },
{ {
name: "with additional build arguments specified", name: "with additional build arguments specified",
inputs: { "build-args": "--target foo\n--parallel 8" }, inputs: { "build-args": `--target foo\n--parallel 8 --foo "bar baz"` },
expectedContext: { expectedContext: {
build: { build: {
enabled: false, enabled: false,
args: ["--target", "foo", "--parallel", "8"], args: ["--target", "foo", "--parallel", "8", "--foo", "bar baz"],
}, },
}, },
}, },
@ -153,7 +153,7 @@ describe("get action context", () => {
options: `BUILD_TESTING=ON BUILD_EXAMPLES=ON\nBUILD_DOCS=ON FOO="BAR BAZ"`, options: `BUILD_TESTING=ON BUILD_EXAMPLES=ON\nBUILD_DOCS=ON FOO="BAR BAZ"`,
args: `-Wdev -Wdeprecated\n--fresh --foo "bar baz"`, args: `-Wdev -Wdeprecated\n--fresh --foo "bar baz"`,
"run-build": "true", "run-build": "true",
"build-args": "--target foo\n--parallel 8", "build-args": `--target foo\n--parallel 8 --foo "bar baz"`,
}, },
expectedContext: { expectedContext: {
sourceDir: "project", sourceDir: "project",
@ -174,7 +174,7 @@ describe("get action context", () => {
}, },
build: { build: {
enabled: true, enabled: true,
args: ["--target", "foo", "--parallel", "8"], args: ["--target", "foo", "--parallel", "8", "--foo", "bar baz"],
}, },
}, },
}, },

View File

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