Skip to content

Commit

Permalink
Merge pull request #22 from DeterminateSystems/string-to-array
Browse files Browse the repository at this point in the history
Provide function for comma-separated string inputs
  • Loading branch information
lucperkins authored Apr 26, 2024
2 parents 5abcb23 + ed9b9e3 commit cd38b22
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ const getBool = (name: string): boolean => {
return actionsCore.getBooleanInput(name);
};

/**
* Convert a comma-separated string input into an array of strings, leaving whitespace intact.
*/
const getCommaSeparatedArrayOfStrings = (
name: string,
stripWhitespace?: boolean,
): string[] => {
const strip = stripWhitespace ?? false;
const original = getString(name);
return (strip ? original.replace(/\s+/g, "") : original).split(",");
};

/**
* Get a multi-line string input from the Action's configuration by name or return `null` if not set.
*/
Expand Down Expand Up @@ -68,6 +80,7 @@ const getStringOrUndefined = (name: string): string | undefined => {

export {
getBool,
getCommaSeparatedArrayOfStrings,
getMultilineStringOrNull,
getNumberOrNull,
getString,
Expand Down

0 comments on commit cd38b22

Please sign in to comment.