Skip to content

Commit

Permalink
Fix package app path
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgef committed Feb 23, 2024
1 parent ecee387 commit e6fc26b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
23 changes: 16 additions & 7 deletions src/common/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,19 @@ export const initStore = () => {
defaultsInt,
} as any);

console.log("_static", getStaticPath());
const staticsPath = getStaticPath();

console.log("_static", staticsPath);

const paths = (await storeInt.get("paths")) || {};

const envPath = path.join(getStaticPath(), "env");
const envPath = path.join(staticsPath, "env");
const configPath = await getConfigPath();
const assetsPath = path.join(getStaticPath(), "assets");
const themesPath = path.join(getStaticPath(), "themes");
const bufferPath = path.join(getStaticPath(), "buffer");
const publicPath = path.join(getStaticPath(), "public");
const vendorPath = path.join(getStaticPath(), "vendor");
const assetsPath = path.join(staticsPath, "assets");
const themesPath = path.join(staticsPath, "themes");
const bufferPath = path.join(staticsPath, "buffer");
const publicPath = path.join(staticsPath, "public");
const vendorPath = path.join(staticsPath, "vendor");

const storeIntPaths = {
...paths,
Expand Down Expand Up @@ -187,6 +189,13 @@ export const initStore = () => {
defaults,
});

/**
* Creating statics dir if it doesn't exist
*/
if (!fs.existsSync(staticsPath)) {
fs.mkdirSync(staticsPath);
}

/**
* Creating themes dir if it doesn't exist
*/
Expand Down
6 changes: 2 additions & 4 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ export const getConfigPath = async () => {
};

export const getRootPath = () => {
const rootPath = app.isPackaged ? app.getPath('appData') : app.getPath('exe').split("node_modules")[0];
console.log("rootPath", rootPath);
return rootPath;
return app.isPackaged ? app.getPath('userData') : app.getPath('exe').split("node_modules")[0];;
}

export const getStaticPath = () => {
return path.join(app.isPackaged ? process.resourcesPath : getRootPath(), 'static');
return path.join(app.isPackaged && !process.resourcesPath?.includes("WindowsApps") ? process.resourcesPath : getRootPath(), 'static');
};
5 changes: 5 additions & 0 deletions src/renderer/components/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import App from "./App";

import cx from "classnames";

// const remote = require("@electron/remote");
// const win = remote.getCurrentWindow();
// const openDevTools = remote.getGlobal("openDevTools");

const Loader: FunctionComponent = () => {
const [isLoading, setIsLoading] = React.useState(true);
const [loadingText, setLoadingText] = React.useState("");
Expand All @@ -22,6 +26,7 @@ const Loader: FunctionComponent = () => {
};

React.useEffect(() => {
//openDevTools();
const init = async () => {
setLoadingText("Initializing Configuration");
await initConfig();
Expand Down

0 comments on commit e6fc26b

Please sign in to comment.