-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix: move to async functions where possible #106
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
rules: { | ||
strict: 'error', | ||
'no-shadow': 0, // XXX: fix this later | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,13 @@ const rimraf = util.promisify(require('rimraf')) | |
|
||
module.exports = rm | ||
|
||
function rm (cache, integrity) { | ||
return hasContent(cache, integrity).then((content) => { | ||
// ~pretty~ sure we can't end up with a content lacking sri, but be safe | ||
if (content && content.sri) { | ||
return rimraf(contentPath(cache, content.sri)).then(() => true) | ||
} else { | ||
return false | ||
} | ||
}) | ||
async function rm (cache, integrity) { | ||
const content = await hasContent(cache, integrity) | ||
// ~pretty~ sure we can't end up with a content lacking sri, but be safe | ||
if (content && content.sri) { | ||
await rimraf(contentPath(cache, content.sri)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we've brought There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just did more review and found that we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this was ONLY supposed to move to |
||
return true | ||
} else { | ||
return false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it took me a second to see what this was doing.. seems like the intent here is to run the code within the
.then()
handler after a short delay?i don't have a solid suggestion for making this more readable,
setImmediate(async () => {})
feels like it would be, but you'd have to also put a try/catch inside the function. maybe just a comment explaining is enough?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I fiddled a bit w/ this, this was as good as it got. The comment was supposed to explain it lol.