Skip to content

Commit

Permalink
fix: fix input array parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
EndBug committed Mar 26, 2024
1 parent aef1d0d commit e22b7b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,22 @@ export function parseInputArray(input: string): string[] {
return json;
}
} catch {
return [];
}

try {
const yaml = YAML.load(input);
if (yaml && Array.isArray(yaml) && yaml.every(e => typeof e === 'string')) {
core.debug(`Input parsed as YAML array of length ${yaml.length}`);
return yaml;
try {
const yaml = YAML.load(input);
if (
yaml &&
Array.isArray(yaml) &&
yaml.every(e => typeof e === 'string')
) {
core.debug(`Input parsed as YAML array of length ${yaml.length}`);
return yaml;
}
} catch {
core.debug('Input parsed as single string');
return [input];
}
} catch {
return [];
}

core.debug('Input parsed as single string');
return [input];
return [];
}

export function readJSON(filePath: string) {
Expand Down

0 comments on commit e22b7b6

Please sign in to comment.