Skip to content

Commit

Permalink
fix: disable autostart when running yarn dev (#575)
Browse files Browse the repository at this point in the history
* fix: disable autostart when running `yarn dev`

* chore: add `package` command to build from source
  • Loading branch information
dubisdev committed Aug 27, 2022
1 parent eaa59bf commit 464b54c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
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

0 comments on commit 464b54c

Please sign in to comment.