Skip to content

chore(dev): getInputList helper func#46

Merged
marcosnils merged 1 commit intodagger:mainfrom
crazy-max:multiline-input
Apr 12, 2022
Merged

chore(dev): getInputList helper func#46
marcosnils merged 1 commit intodagger:mainfrom
crazy-max:multiline-input

Conversation

@crazy-max
Copy link
Copy Markdown
Contributor

follow-up #44 (comment)

Adds getInputList func. I don't use the getMultilineInput from the core module because because it lacks some sanitizing logic and also doesn't handle comma delimiter that could be useful in the future.

Also adds asyncForEach so you could iterate over this list for the multi args feature we talked about.

cc @marcosnils @joaofnds

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

Comment thread __tests__/context.test.ts Outdated
Comment thread __tests__/context.test.ts Outdated
Comment thread src/context.ts
Comment on lines +22 to +32
const items = core.getInput(name);
if (items == '') {
return [];
}
return items
.split(/\r?\n/)
.filter(x => x)
.reduce<string[]>(
(acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()),
[]
);
Copy link
Copy Markdown
Contributor

@joaofnds joaofnds Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const items = core.getInput(name);
if (items == '') {
return [];
}
return items
.split(/\r?\n/)
.filter(x => x)
.reduce<string[]>(
(acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()),
[]
);
const items = core.getInput(name);
if (items == '') {
return [];
}
let splitCharSet = '\r\n'
if (!ignoreComma) splitCharSet += ','
return items
.split(new RegExp(`[${splitCharSet}]`))
.filter(x => x)
.map(pat => pat.trim());

Comment thread src/context.ts Outdated
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #46 (d0d5d21) into main (14118c6) will decrease coverage by 4.59%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
- Coverage   94.59%   90.00%   -4.60%     
==========================================
  Files           1        2       +1     
  Lines          37       50      +13     
  Branches        7        9       +2     
==========================================
+ Hits           35       45      +10     
- Misses          1        3       +2     
- Partials        1        2       +1     
Impacted Files Coverage Δ
src/context.ts 76.92% <80.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 14118c6...d0d5d21. Read the comment docs.

@marcosnils marcosnils merged commit d1bb14c into dagger:main Apr 12, 2022
@crazy-max crazy-max deleted the multiline-input branch April 12, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants