-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Use fs.access
instead of fs.existsSync
#350
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
Conversation
var fs = require('fs') | ||
const basePath = path.join(__dirname, '..', '..', 'locale', 'en', 'blog', 'weekly-updates') | ||
const client = github.client() | ||
const evRepo = client.repo('nodejs/evangelism') |
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.
Since you are refactoring, you can directly create evRepo without those intermediate requires.
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.
Sure.
52d8b33
to
285a901
Compare
Change LGTM. Do you know why CI is not run for this PR? |
No clue. |
285a901
to
cfea8c1
Compare
@thefourtheye please check again. |
LGTM. Some error handling on the HTTPS request and file writing would be nice, but that could be another PR. |
https.get(downloadUrl, function (response) { | ||
response.pipe(outputFile) | ||
https.get(file.download_url, function (response) { | ||
response.pipe(fs.createWriteStream(filePath)) |
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.
Would it be better if we notified the user once the downloading is complete?
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.
Any idea on what kind of message? Something like this?
console.log(`Weekly Update ${filePath} downloaded.`);
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.
We already log the filePath. So wouldn't Download completed
be better?
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 would help to understand what file the message refers to, otherwise with multiple files, it can be confusing, but yes a simple "Download completed" can work too.
cfea8c1
to
fdedf38
Compare
@phillipj do you know why CI is not run for this PR? |
https.get(downloadUrl, function (response) { | ||
response.pipe(outputFile) | ||
https.get(file.download_url, function (response) { | ||
console.log(`Weekly Update ${filePath} downloaded.`) |
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.
@thefourtheye If you feel strong about using only "Download completed.", I'll change this.
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.
This actually should have been
response.on('end', () => console.log(`Weekly Update ${filePath} downloaded.`))
@thefourtheye no idea why it doesn't show inline in the PR.. These commits are visible in the Travis/new.nodejs.org build history though, might be a github hickup? |
PTAL. |
Still looks fine to me. But I would be confident if CI ran. |
https://travis-ci.org/nodejs/new.nodejs.org/builds/90492242 is the build for @lpinca latest commit ba338a5 |
Use `fs.access` instead of `fs.existsSync`
Cool. Merged now. 👍 Thanks @phillipj :-) |
The reason behind this change is that
fs.exists
and its sync version are deprecated.