Cli: refactor: use async fs calls in src/utils/proxy.js

Created on 23 Sep 2020  路  5Comments  路  Source: netlify/cli

Describe the bug

This file could easily use the async versions of the fs functions instead of the sync ones.

Additional context

See: https://github.com/netlify/cli/pull/1271#discussion_r493164135

area dev good first issue chore

Most helpful comment

If you don't mind, I want to challenge to fix this issue !

All 5 comments

If you don't mind, I want to challenge to fix this issue !

Thanks @mugi111, I assigned you to the issue. Please let me know if there is anything you need.

https://github.com/netlify/cli/blob/5c9fed77e3aaa632c154000180d692ca0742dd1a/src/utils/proxy.js#L235
Let me ask for advice on how to fix this.
Is it correct to filter the headersFiles with fs.stat() and isFiles() once and then use map() for that array?

You could use https://github.com/sindresorhus/p-filter to filter promises, then run map in the result.
You can use https://github.com/netlify/cli/blob/5c9fed77e3aaa632c154000180d692ca0742dd1a/src/lib/fs.js#L18 for the filter

Thank you. It was helpful.
I'll deal with it that way.

Was this page helpful?
0 / 5 - 0 ratings