Merge 347401464b4b438f931b00f4cafa88f5e9891263 into 3edfce9056124e459a23f683a21433670d47daca

This commit is contained in:
Nikita D 2026-11-08 03:45:15 +00:00 committed by GitHub
commit 6ab5402b55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 118 additions and 6 deletions

View File

@ -176,6 +176,38 @@ test("getInputAsArray removes spaces after ! at the beginning", () => {
]);
});
test("getInputAsArray handles YAML list format (JSON array)", () => {
testUtils.setInput("foo", '["bar", "baz", "qux"]');
expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz", "qux"]);
});
test("getInputAsArray handles YAML list format with exclusion patterns", () => {
testUtils.setInput(
"foo",
'["~/cache", "! ~/cache/exclude", "**/node_modules"]'
);
expect(actionUtils.getInputAsArray("foo")).toEqual([
"~/cache",
"!~/cache/exclude",
"**/node_modules"
]);
});
test("getInputAsArray handles YAML list format with empty strings", () => {
testUtils.setInput("foo", '["bar", "", "baz", " ", "qux"]');
expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz", "qux"]);
});
test("getInputAsArray handles invalid JSON gracefully and falls back to newline parsing", () => {
testUtils.setInput("foo", "[invalid json");
expect(actionUtils.getInputAsArray("foo")).toEqual(["[invalid json"]);
});
test("getInputAsArray handles JSON that is not an array", () => {
testUtils.setInput("foo", '{"key": "value"}');
expect(actionUtils.getInputAsArray("foo")).toEqual(['{"key": "value"}']);
});
test("getInputAsInt returns undefined if input not set", () => {
expect(actionUtils.getInputAsInt("undefined")).toBeUndefined();
});

View File

@ -94969,7 +94969,23 @@ function isValidEvent() {
return RefKey in process.env && Boolean(process.env[RefKey]);
}
function getInputAsArray(name, options) {
return getInput(name, options)
const input = getInput(name, options);
// Try to parse as JSON array (YAML list format)
if (input.startsWith("[")) {
try {
const parsed = JSON.parse(input);
if (Array.isArray(parsed)) {
return parsed
.map(s => String(s).replace(/^!\s+/, "!").trim())
.filter(x => x !== "");
}
}
catch {
// Not valid JSON, fall through to newline parsing
}
}
// Fall back to newline-separated format
return input
.split("\n")
.map(s => s.replace(/^!\s+/, "!").trim())
.filter(x => x !== "");

18
dist/restore/index.js vendored
View File

@ -94969,7 +94969,23 @@ function isValidEvent() {
return RefKey in process.env && Boolean(process.env[RefKey]);
}
function getInputAsArray(name, options) {
return getInput(name, options)
const input = getInput(name, options);
// Try to parse as JSON array (YAML list format)
if (input.startsWith("[")) {
try {
const parsed = JSON.parse(input);
if (Array.isArray(parsed)) {
return parsed
.map(s => String(s).replace(/^!\s+/, "!").trim())
.filter(x => x !== "");
}
}
catch {
// Not valid JSON, fall through to newline parsing
}
}
// Fall back to newline-separated format
return input
.split("\n")
.map(s => s.replace(/^!\s+/, "!").trim())
.filter(x => x !== "");

View File

@ -94974,7 +94974,23 @@ function isValidEvent() {
return RefKey in process.env && Boolean(process.env[RefKey]);
}
function getInputAsArray(name, options) {
return getInput(name, options)
const input = getInput(name, options);
// Try to parse as JSON array (YAML list format)
if (input.startsWith("[")) {
try {
const parsed = JSON.parse(input);
if (Array.isArray(parsed)) {
return parsed
.map(s => String(s).replace(/^!\s+/, "!").trim())
.filter(x => x !== "");
}
}
catch {
// Not valid JSON, fall through to newline parsing
}
}
// Fall back to newline-separated format
return input
.split("\n")
.map(s => s.replace(/^!\s+/, "!").trim())
.filter(x => x !== "");

18
dist/save/index.js vendored
View File

@ -94974,7 +94974,23 @@ function isValidEvent() {
return RefKey in process.env && Boolean(process.env[RefKey]);
}
function getInputAsArray(name, options) {
return getInput(name, options)
const input = getInput(name, options);
// Try to parse as JSON array (YAML list format)
if (input.startsWith("[")) {
try {
const parsed = JSON.parse(input);
if (Array.isArray(parsed)) {
return parsed
.map(s => String(s).replace(/^!\s+/, "!").trim())
.filter(x => x !== "");
}
}
catch {
// Not valid JSON, fall through to newline parsing
}
}
// Fall back to newline-separated format
return input
.split("\n")
.map(s => s.replace(/^!\s+/, "!").trim())
.filter(x => x !== "");

View File

@ -40,8 +40,24 @@ export function getInputAsArray(
name: string,
options?: core.InputOptions
): string[] {
return core
.getInput(name, options)
const input = core.getInput(name, options);
// Try to parse as JSON array (YAML list format)
if (input.startsWith("[")) {
try {
const parsed = JSON.parse(input);
if (Array.isArray(parsed)) {
return parsed
.map(s => String(s).replace(/^!\s+/, "!").trim())
.filter(x => x !== "");
}
} catch {
// Not valid JSON, fall through to newline parsing
}
}
// Fall back to newline-separated format
return input
.split("\n")
.map(s => s.replace(/^!\s+/, "!").trim())
.filter(x => x !== "");