-
Notifications
You must be signed in to change notification settings - Fork 656
Description
The export structure of the path
module looks like this:
export const posix = {
basename,
dirname,
extname,
...
};
export const win32 = {
basename,
dirname,
extname,
...
};
export {
basename,
dirname,
extname,
...,
globToRegExp,
normalizeGlob,
SEP,
SEP_PATTERN,
...
};
This seems archaic and overly bound to where we vendored the implementation. It forces us to put group every function by OS in just path/posix.ts
and path/win32.ts
, rather than having modules like path/join.ts
, path/file_url.ts
, etc. It's hard to maintain and the test modules don't match it.
We should instead export one set of functions which each have an options interface containing the OS. They all have few enough positional arguments. This is modelled already by path/glob.ts
, which gets to have its own module, containing:
export interface GlobOptions {
...,
/** Operating system. Defaults to the native OS. */
os?: typeof Deno.build.os;
}
These functions can branch by OS individually.
The current structure allows importing one namespace of functions for another OS, but this is niche enough that users should make such an abstraction themselves if they need it (in reality they can just import it from the node/
polyfill).