mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: check if process is defined before using so it works in browser (#4497)
* refactor: use isTestEnv() utils where applicable * check if process is defined
This commit is contained in:
parent
38236bc5e0
commit
11396a21de
3 changed files with 7 additions and 7 deletions
|
@ -443,8 +443,7 @@ export const bytesToHexString = (bytes: Uint8Array) => {
|
|||
.join("");
|
||||
};
|
||||
|
||||
export const getUpdatedTimestamp = () =>
|
||||
process.env.NODE_ENV === "test" ? 1 : Date.now();
|
||||
export const getUpdatedTimestamp = () => (isTestEnv() ? 1 : Date.now());
|
||||
|
||||
/**
|
||||
* Transforms array of objects containing `id` attribute,
|
||||
|
@ -459,4 +458,5 @@ export const arrayToMap = <T extends { id: string } | string>(
|
|||
}, new Map());
|
||||
};
|
||||
|
||||
export const isTestEnv = () => process?.env?.NODE_ENV === "test";
|
||||
export const isTestEnv = () =>
|
||||
typeof process !== "undefined" && process.env?.NODE_ENV === "test";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue