Skip to content

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

Merged
merged 3 commits into from
Nov 11, 2015
Merged

Use fs.access instead of fs.existsSync #350

merged 3 commits into from
Nov 11, 2015

Conversation

lpinca
Copy link
Member

@lpinca lpinca commented Nov 11, 2015

The reason behind this change is that fs.exists and its sync version are deprecated.

var fs = require('fs')
const basePath = path.join(__dirname, '..', '..', 'locale', 'en', 'blog', 'weekly-updates')
const client = github.client()
const evRepo = client.repo('nodejs/evangelism')
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

@thefourtheye
Copy link
Contributor

Change LGTM. Do you know why CI is not run for this PR?

@lpinca
Copy link
Member Author

lpinca commented Nov 11, 2015

No clue.

@lpinca
Copy link
Member Author

lpinca commented Nov 11, 2015

@thefourtheye please check again.

@phillipj
Copy link
Member

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))
Copy link
Contributor

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?

Copy link
Member Author

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.`);

Copy link
Contributor

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?

Copy link
Member Author

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.

@thefourtheye
Copy link
Contributor

@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.`)
Copy link
Member Author

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.

Copy link
Contributor

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.`))

@phillipj
Copy link
Member

@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?

@lpinca
Copy link
Member Author

lpinca commented Nov 11, 2015

PTAL.

@thefourtheye
Copy link
Contributor

Still looks fine to me. But I would be confident if CI ran.

@phillipj
Copy link
Member

https://travis-ci.org/nodejs/new.nodejs.org/builds/90492242 is the build for @lpinca latest commit ba338a5

thefourtheye added a commit that referenced this pull request Nov 11, 2015
Use `fs.access` instead of `fs.existsSync`
@thefourtheye thefourtheye merged commit 87912b7 into master Nov 11, 2015
@thefourtheye thefourtheye deleted the use/fs.access branch November 11, 2015 10:43
@thefourtheye
Copy link
Contributor

Cool. Merged now. 👍 Thanks @phillipj :-)

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.

3 participants