-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use Node's path helpers under NODERAWFS #17849
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
isAbs: (path) => nodePath['isAbsolute'](path), | ||
normalize: (path) => nodePath['normalize'](path), | ||
dirname: (path) => nodePath['dirname'](path), | ||
basename: (path) => nodePath['basename'](path), |
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.
I'm curious why closure wouldn't know how to deal with nodePath without the extra quoting here?
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.
Good point, it's currently used this way throughout the codebase. Perhaps nodePath
should be placed within src/closure-externs/closure-externs.js
?
basename: (path) => nodePath['basename'](path), | ||
join: function () { | ||
return nodePath['join'].apply(null, arguments); | ||
}, |
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.
Can this just be join: nodePath['join']
? (same with above)
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.
I tried that initially, but it caused the acorn-optimizer to fail.
Tested it with the scenarios I had in #17821- works great. Thanks. I had added some window specific tests in that PR, @kleisauke do you think they would be appropriate here? |
@rchiodo Great, thanks for testing! I just added a simple test that previously failed on Windows. |
Ensures that absolute paths are handled correctly on Windows as well. Using these helpers should be safe, since binaries linked with -sNODERAWFS can only be used on Node.js.
It already resolves to `FS.cwd()` by default, so there's no need to pass it as first argument.
The `PATH_FS.resolve` invocation above already made the path absolute.
a5dc19c
to
07ebf5a
Compare
Rebased now that PR #17851 has been merged. |
Is there anything I can do to make this land? AFAIK, |
* Copyright 2022 The Emscripten Authors | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
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.
Maybe add a comment in this file explaining the motivation for it? (which IIUC from the discussion is windows?) lgtm with that.
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.
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.
Thanks!
Ensures that absolute paths are handled correctly on Windows as well. Using these helpers should be safe, since binaries linked with -sNODERAWFS can only be used on Node.js.
Ensures that absolute paths are handled correctly on Windows as well. Using these helpers should be safe, since binaries linked with
-sNODERAWFS
can only be used on Node.js, see:emscripten/src/library_noderawfs.js
Line 28 in e98554f
Context: #16296 (comment).
Resolves: #17360.
Resolves: #17819.
Supersedes: #17821.
(If preferred, I can split the last
32 non-functional changes)