Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable autostart when running yarn dev #575

Merged
merged 2 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,22 @@ And then install dependencies:
yarn
```

### Run
### Run in development mode

```bash
$ yarn run dev
```

> Note: requires a node version >=16.x
### Build executable from source

If you would like to install one version but the package is not published you can use this command to build executable file from source:

```bash
$ yarn package
```

> Note: in CI we use `yarn build` as there is an action to package and publish the executables
### Resolve common issues
1. `AssertionError: Current node version is not supported for development` on npm postinstall.
After `yarn` postinstall script checks node version. If you see this error you have to check node and npm version in `package.json` `devEngines` section and install proper ones.
Expand All @@ -89,14 +97,6 @@ Use shortcut `ctrl+space` to open app window and type `Cerebro Settings`. There

*macOS*: `~/Library/Application Support/Cerebro/config.json`


### Package
Use this command to build `.app` file:

```bash
$ yarn build
```

## For developers

### Publish a release
Expand Down
16 changes: 9 additions & 7 deletions app/main/createWindow/autoStart.js
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 }
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"start-hot": "yarn build-main-dev && cross-env HOT=1 NODE_ENV=development ./node_modules/.bin/electron -r @babel/register ./app",
"release": "build -mwl --draft",
"dev": "run-p hot-server start-hot",
"postinstall": "electron-builder install-app-deps"
"postinstall": "electron-builder install-app-deps",
"package": "yarn build && npx electron-builder"
},
"build": {
"productName": "Cerebro",
Expand Down