UNPKG

universal-fs

Version:

Allows a client or server to access the file system in the current codebase or a different one.

16 lines (13 loc) 342 B
import {isBrowser, isNode} from "browser-or-node"; import getCookie from "./getCookie"; const getUrl = async () => { let url; if (isBrowser) { url = getCookie("universal-fs-url"); } else if (isNode) { const fs = await import("fs"); url = fs.readFileSync(".fs/url.txt", "utf8"); } return url; }; export default getUrl;