Skip to content

Commit

Permalink
Fix storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed May 29, 2024
1 parent 0524d64 commit e8ce6a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/electron/frontend/core/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const reloadPageToHome = () => {
// Filesystem Management
const root = isTestEnvironment ? joinPath(paths.root, ".test") : paths.root;

export const homeDirectory = os.homedir();
export const homeDirectory = os ? os.homedir() : "/";

export const appDirectory = joinPath(homeDirectory, root);

Expand All @@ -35,9 +35,9 @@ export const testDataFolderPath = joinPath(appDirectory, ...paths.subfolders.tes
// Encryption
const IV_LENGTH = 16;
const KEY_LENGTH = 32;
export const ENCRYPTION_KEY = Buffer.concat([Buffer.from(appDirectory), Buffer.alloc(KEY_LENGTH)], KEY_LENGTH);
export const ENCRYPTION_KEY = isElectron ? Buffer.concat([Buffer.from(appDirectory), Buffer.alloc(KEY_LENGTH)], KEY_LENGTH) : ""

export const ENCRYPTION_IV = crypto.randomBytes(IV_LENGTH);
export const ENCRYPTION_IV = isElectron ? crypto.randomBytes(IV_LENGTH) : "";

// Storybook
export const isStorybook = window.location.href.includes("iframe.html");
Expand Down
12 changes: 6 additions & 6 deletions src/electron/frontend/utils/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ export const isElectron = userAgent.indexOf(" electron/") > -1;
export const electron = globalThis.electron ?? {}; // ipcRenderer, remote, shell, etc.

// Node Modules
export const fs = require("fs-extra"); // File System
export const os = require("os");
export const crypto = require("crypto");
export const path = require("path");
export const fs = isElectron && require("fs-extra"); // File System
export const os = isElectron && require("os");
export const crypto = isElectron && require("crypto");
export const path = isElectron && require("path");

// Remote Electron Modules
export const remote = isElectron ? require("@electron/remote") : {};
export const app = remote.app;

// Electron Information
export const port = electron.ipcRenderer ? electron.ipcRenderer.sendSync("get-port") : 4242;
export const SERVER_FILE_PATH = electron.ipcRenderer ? electron.ipcRenderer.sendSync("get-server-file-path") : "";
export const port = isElectron ? electron.ipcRenderer.sendSync("get-port") : 4242;
export const SERVER_FILE_PATH = isElectron ? electron.ipcRenderer.sendSync("get-server-file-path") : "";

// Link the renderer to the main process
if (isElectron) {
Expand Down

0 comments on commit e8ce6a0

Please sign in to comment.