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

fix: workaround misleading node.js ENOENT error #11160

Merged
merged 1 commit into from Feb 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/babel-register/src/cache.js
Expand Up @@ -43,6 +43,9 @@ export function save() {
fs.writeFileSync(FILENAME, serialised);
} catch (e) {
switch (e.code) {
// workaround https://github.com/nodejs/node/issues/31481
// todo: remove the ENOENT error check when we drop node.js 13 support
case "ENOENT":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that it's okay to place ENOENT here because write(2) will never throws ENOENT. http://man7.org/linux/man-pages/man2/write.2.html

So ENOENT must be thrown from fs.mkdirSync(#, { recursive: true }).

case "EACCES":
case "EPERM":
console.warn(
Expand Down