Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tool-cache #12

Merged
merged 21 commits into from
Jun 6, 2019
Merged

Add tool-cache #12

merged 21 commits into from
Jun 6, 2019

Conversation

damccorm
Copy link
Contributor

No description provided.

Copy link
Contributor

@jclem jclem left a comment

Choose a reason for hiding this comment

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

Added some little notes here and there. Great work, thank you!

I can't get these tests to pass—do I have to run these in a container for them to work?

packages/tool-cache/__tests__/tool-cache.test.ts Outdated Show resolved Hide resolved
packages/tool-cache/__tests__/tool-cache.test.ts Outdated Show resolved Hide resolved
packages/tool-cache/__tests__/tool-cache.test.ts Outdated Show resolved Hide resolved
packages/tool-cache/package.json Outdated Show resolved Hide resolved
packages/tool-cache/src/tool-cache.ts Outdated Show resolved Hide resolved
packages/tool-cache/src/tool-cache.ts Outdated Show resolved Hide resolved
* @returns path to downloaded tool
*/
export async function downloadTool(url: string): Promise<string> {
return new Promise<string>(async (resolve, reject) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to construct a promise here manually, do we? If so, I think a comment is warranted. Keep in mind that async functions implicitly return a promise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrapped it so that I can resolve from within the stream callbacks. e.g.

file.on('open', async () => {
   *do stuff*
   resolve
})

If I just return normally there, it just returns from the callback. Is there an easier way to handle that? Added a comment for now

packages/tool-cache/src/tool-cache.ts Outdated Show resolved Hide resolved
packages/tool-cache/src/tool-cache.ts Outdated Show resolved Hide resolved

dest = dest || (await _createExtractFolder(dest))

if (IS_WINDOWS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should introduce a pattern for OS splitting—rather than this IS_WINDOWS branch, does it make sense to do something like:

IS_WINDOWS ? extractZipWin() : extractZipNix()

Do you think this would improve readabilty of these branches?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it here, not sure how useful I see it being in other places - I think most of these splits are pretty small amounts of code compared to this one.

I also ditched the ? : syntax in favor of traditional if else because it felt a little crowded with the awaits thrown in.

@jclem jclem mentioned this pull request Jun 4, 2019
@damccorm damccorm merged commit 71a9b2d into master Jun 6, 2019
@damccorm damccorm deleted the features/tool-cache branch June 7, 2019 19:21
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.

2 participants