From aabbb8772d73e7cec8071e7da2789b8741b7a948 Mon Sep 17 00:00:00 2001 From: sj Date: Fri, 11 Apr 2025 10:19:26 +0200 Subject: [PATCH] Support specifying the profile dir path via env var (#2226) (#2246) --- src/electron-main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/electron-main.ts b/src/electron-main.ts index 6b243f75..b2263a65 100644 --- a/src/electron-main.ts +++ b/src/electron-main.ts @@ -44,7 +44,12 @@ const argv = minimist(process.argv, { if (argv["help"]) { console.log("Options:"); console.log(" --profile-dir {path}: Path to where to store the profile."); - console.log(" --profile {name}: Name of alternate profile to use, allows for running multiple accounts."); + console.log( + ` --profile {name}: Name of alternate profile to use, allows for running multiple accounts.\n` + + ` Ignored if --profile-dir is specified.\n` + + ` The ELEMENT_PROFILE_DIR environment variable may be used to change the default profile path.\n` + + ` It is overridden by --profile-dir, but can be combined with --profile.`, + ); console.log(" --devtools: Install and use react-devtools and react-perf."); console.log( ` --config: Path to the config.json file. May also be specified via the ELEMENT_DESKTOP_CONFIG_JSON environment variable.\n` + @@ -75,7 +80,7 @@ if (userDataPathInProtocol) { } else if (argv["profile-dir"]) { userDataPath = argv["profile-dir"]; } else { - let newUserDataPath = app.getPath("userData"); + let newUserDataPath = process.env.ELEMENT_PROFILE_DIR ?? app.getPath("userData"); if (argv["profile"]) { newUserDataPath += "-" + argv["profile"]; }