-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable autostart when running
yarn dev
(#575)
* fix: disable autostart when running `yarn dev` * chore: add `package` command to build from source
- Loading branch information
Showing
3 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import { app } from 'electron' | ||
import AutoLaunch from 'auto-launch' | ||
|
||
let appLauncher | ||
const isLinux = !['win32', 'darwin'].includes(process.platform) | ||
const isDevelopment = process.env.NODE_ENV === 'development' | ||
|
||
const isLinux = ['win32', 'darwin'].indexOf(process.platform) === -1 | ||
|
||
if (isLinux) { appLauncher = new AutoLaunch({ name: 'Cerebro' }) } | ||
const appLauncher = isLinux | ||
? new AutoLaunch({ name: 'Cerebro' }) | ||
: null | ||
|
||
const isEnabled = async () => ( | ||
isLinux | ||
? appLauncher.isEnabled() | ||
: app.getLoginItemSettings().openAtLogin | ||
) | ||
|
||
const set = (openAtLogin) => { | ||
const set = async (openAtLogin) => { | ||
const openAtStartUp = openAtLogin && !isDevelopment | ||
if (isLinux) { | ||
return openAtLogin | ||
return openAtStartUp | ||
? appLauncher.enable() | ||
: appLauncher.disable() | ||
} | ||
|
||
return app.setLoginItemSettings({ openAtLogin }) | ||
return app.setLoginItemSettings({ openAtLogin: openAtStartUp }) | ||
} | ||
|
||
export default { isEnabled, set } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters