Skip to content

Commit 79f4e69

Browse files
authored
Merge pull request #4160 from usebruno/feature/custom-user-data-path-for-dev
2 parents 942c0ee + f13148a commit 79f4e69

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

contributing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ npm run dev:electron
9898
npm run dev
9999
```
100100

101+
#### Customize Electron `userData` path
102+
If `ELECTRON_APP_NAME` env-variable is present and its development mode, then the `appName` and `userData` path is modified accordingly.
103+
104+
e.g.
105+
```sh
106+
ELECTRON_APP_NAME=bruno-dev npm run dev:electron
107+
```
108+
109+
> This doesn't change the name of the window or the names in lot of other places, only the name used by Electron internally.
110+
101111
### Troubleshooting
102112

103113
You might encounter a `Unsupported platform` error when you run `npm install`. To fix this, you will need to delete `node_modules` and `package-lock.json` and run `npm install`. This should install all the necessary packages needed to run the app.

packages/bruno-electron/src/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ const { format } = require('url');
1414
const { BrowserWindow, app, session, Menu, ipcMain } = require('electron');
1515
const { setContentSecurityPolicy } = require('electron-util');
1616

17+
if (isDev && process.env.ELECTRON_APP_NAME) {
18+
const appName = process.env.ELECTRON_APP_NAME;
19+
const userDataPath = path.join(app.getPath("appData"), appName);
20+
21+
console.log("`ELECTRON_APP_NAME` found, overriding `appName` and `userData` path: \n"
22+
+ `\t${app.getName()} -> ${appName}\n`
23+
+ `\t${app.getPath("userData")} -> ${userDataPath}`);
24+
25+
app.setName(appName);
26+
app.setPath("userData", userDataPath);
27+
}
28+
1729
const menuTemplate = require('./app/menu-template');
1830
const { openCollection } = require('./app/collections');
1931
const LastOpenedCollections = require('./store/last-opened-collections');

0 commit comments

Comments
 (0)