Skip to content

remove path monkey patch #2698

@snebjorn

Description

@snebjorn

Currently path is being monkey patched

for (const [propName, propValue] of Object.entries(basepath)) {
if (isFunction(propValue)) {
// @ts-ignore
path[propName] = ((propName) => {
return (...args: any[]) => {
args = args.map((p) => {
return isString(p) ? toUnix(p) : p;
});
// @ts-ignore
const result = basepath[propName](...args);
return isString(result) ? toUnix(result) : result;
};
})(propName);
} else {
// @ts-ignore
path[propName] = propValue;
}
}

While this works, it muddy the waters ☹️

Example:

// example A
import path from 'node:path';
// example B
import path from 'node:path';
import { upath } from '../utils';

Using path will do different things in example A and B.

I took a stab at it a while back, but it's non-obvious (to me) where the real path and the monkey patched path is being used so I focused on other things 😄

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions