Skip to content

Commit

Permalink
Fix browser dependency for lstats
Browse files Browse the repository at this point in the history
  • Loading branch information
ajredniwja committed Mar 22, 2021
1 parent 19f978c commit 45999f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/lib-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
},
"browser": {
"stream": "stream-browserify",
"fs": "./src/runtimeConfig.browser",
"./runtimeConfig": "./src/runtimeConfig.browser"
},
"react-native": {
Expand Down
4 changes: 2 additions & 2 deletions lib/lib-storage/src/bytelength.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lstatSync } from "fs";
import { ClientDefaultValues } from "./runtimeConfig";

export const byteLength = (input: any) => {
if (input === null || input === undefined) return 0;
Expand All @@ -11,7 +11,7 @@ export const byteLength = (input: any) => {
return input.size;
} else if (typeof input.path === "string") {
try {
return lstatSync(input.path).size;
return ClientDefaultValues.lstatSync(input.path).size;
} catch (error) {
return undefined;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/lib-storage/src/runtimeConfig.shared.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/**
* @internal
*/
export const ClientSharedValues = {};
export const ClientSharedValues = {
lstatSync: () => {},
};
2 changes: 2 additions & 0 deletions lib/lib-storage/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ClientSharedValues } from "./runtimeConfig.shared";
import { lstatSync } from "fs";

/**
* @internal
*/
export const ClientDefaultValues = {
...ClientSharedValues,
runtime: "node",
lstatSync,
};

0 comments on commit 45999f0

Please sign in to comment.