Skip to content

Commit

Permalink
fix: check process.cwd before calling it
Browse files Browse the repository at this point in the history
Some runtimes (like React Native) has a `process` global, but doesn't provide a `cwd` function. Instead of assuming the `cwd` function is available, just because the `process` global is, merging this PR will update the check to actually verify the `process.cwd` is a callable function before relying on it.
  • Loading branch information
kraenhansen committed Nov 14, 2023
1 parent b7ff533 commit fd8520e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const join: typeof path.join = function (...arguments_) {
};

function cwd() {
if (typeof process !== "undefined") {
if (typeof process !== "undefined" && typeof process.cwd === "function") {
return process.cwd().replace(/\\/g, "/");
}
return "/";
Expand Down

0 comments on commit fd8520e

Please sign in to comment.