-
Notifications
You must be signed in to change notification settings - Fork 632
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
refactor: split path into per-os modules #3649
Conversation
const constants: GlobConstants = { | ||
sep: "/+", | ||
sepMaybe: "/*", | ||
seps: ["/"], | ||
globstar: "(?:[^/]*(?:/|$)+)*", | ||
wildcard: "[^/]*", | ||
escapePrefix: "\\", | ||
}; |
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 looks nice
Maybe web can move |
export type GlobToRegExpOptions = GlobOptions & { | ||
os?: OSType; |
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.
Is this kept because of backward compatibility? Do you think it's good idea to keep this option in the future?
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 was mainly so that the tests still work, personally I think the os
option should be ditched entirely otherwise it's inconsistent with the other path fns, but the tests will need reworking to account for that.
path/win32.ts
Outdated
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 wonder if we should also deprecate this path (and also path/posix.ts
).
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 be useful to be able to deprecate an entire module, so that it's import statement and/or all imported members display with usual deprecated strike-through, but I'm not sure there is a way to do that is there?
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.
Probably need to alias items and deprecate the aliases.
import * as path from "./windows/mod.ts";
/** @deprecated (will be removed after 0.210.0) Import from `path/windows/mod.ts` instead. */
export const sep = path.sep;
/** @deprecated (will be removed after 0.210.0) Import from `path/windows/mod.ts` instead. */
export const delimiter = path.delimiter;
/** @deprecated (will be removed after 0.210.0) Import from `path/windows/mod.ts` instead. */
export const resolve = path.resolve;
...
This should be backward compatible from my understanding. Mostly looks good to me. I wonder if it makes sense to have |
I think it makes sense to keep it purely for the sake of API consistency between |
Ok. Makes sense. |
Is there anything remaining with this PR? |
I was just looking into this and noticed that there is an inconsistency in the options. The GlobOptions jsdoc says Also, these fns are pretty simple and rely on platform specific imports (eg. SEP, SEP_PATTERN, normalize, join), which would have to be passed into a common fn, I think it may just be simplier to retain the platform specific implementations of each. |
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.
LGTM. Nice work!
Splits path functions into a module per platform and common fns.
Also applied the pattern to glob.
As discussed in #3553
Also see #3600