Skip to content

Commit 85772fc

Browse files
author
Akos Kitta
committed
Set XDG_CONFIG_HOME env on Linux when not set.
Otherwise, `node-log-rotate` creates a folder with `undefined` name. Closes #394. Signed-off-by: Akos Kitta <[email protected]>
1 parent 36ac47b commit 85772fc

File tree

1 file changed

+14
-0
lines changed
  • electron/build/patch/backend

1 file changed

+14
-0
lines changed

Diff for: electron/build/patch/backend/main.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
// @ts-check
2+
3+
// Patch for on Linux when `XDG_CONFIG_HOME` is not available, `node-log-rotate` creates the folder with `undefined` name.
4+
// See https://github.com/lemon-sour/node-log-rotate/issues/23 and https://github.com/arduino/arduino-ide/issues/394.
5+
// If the IDE2 is running on Linux, and the `XDG_CONFIG_HOME` variable is not available, set it to avoid the `undefined` folder.
6+
// From the specs: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
7+
// "If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used."
8+
const os = require('os');
9+
if (os.platform() === 'linux' && !process.env['XDG_CONFIG_HOME']) {
10+
const { join } = require('path');
11+
const home = process.env['HOME'];
12+
const xdgConfigHome = home ? join(home, '.config') : join(os.homedir(), '.config');
13+
process.env['XDG_CONFIG_HOME'] = xdgConfigHome;
14+
}
15+
216
const { setup, log } = require('node-log-rotate');
317
setup({
418
appName: 'Arduino IDE',

0 commit comments

Comments
 (0)