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: { configure: {
generator: getInput("generator"), generator: getInput("generator"),
options, options,
args: getInput("args") args: shellQuoteExports.parse(getInput("args")).map((arg) => arg.toString()),
.split(/\s+/)
.filter((arg) => arg != ""),
}, },
build: { build: {
enabled: getInput("run-build") == "true", enabled: getInput("run-build") == "true",

View File

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

View File

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