Skip to content

chore: add cerebro version to process.env #585

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

Merged
merged 2 commits into from
Sep 9, 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
2 changes: 2 additions & 0 deletions app/main.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ if (process.env.NODE_ENV !== 'development') {
}

app.whenReady().then(() => {
process.env.CEREBRO_VERSION = app.getVersion()

mainWindow = createMainWindow({
isDev,
src: `file://${__dirname}/main/index.html`, // Main window html
Expand Down
5 changes: 3 additions & 2 deletions app/plugins/core/version/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { search } from 'cerebro-tools'
import icon from '../icon.png'
import { version } from '../../../../package.json'

// Settings plugin name
const NAME = 'Cerebro Version'
Expand All @@ -16,6 +15,8 @@ const KEYWORDS = [
'version'
]

const { CEREBRO_VERSION } = process.env

/**
* Plugin to show app settings in results list
*
Expand All @@ -31,7 +32,7 @@ const versionPlugin = ({ term, display, actions }) => {
icon,
title: NAME,
term: NAME,
getPreview: () => (<div><strong>{version}</strong></div>),
getPreview: () => (<div><strong>{CEREBRO_VERSION}</strong></div>),
onSelect: (event) => {
event.preventDefault()
actions.replaceTerm(NAME)
Expand Down
10 changes: 8 additions & 2 deletions docs/plugins/plugin-structure.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <a href="../plugins.md">Plugins</a> → Plugin structure
# [Plugins](../plugins.md) → Plugin structure

This is a minimum source code of your plugin:

Expand Down Expand Up @@ -91,7 +91,7 @@ Arguments: `event: Event`

Action, that should be executed when user selects your result. I.e, to open provided url in default browser:

```
```js
onSelect: (event) => actions.open(`http://www.cerebroapp.com`),
```

Expand Down Expand Up @@ -183,3 +183,9 @@ This object is used to specify settings that a plugin user can change. Each sett
Check `settings` [example](./examples.md#using-settings)

Look at [React Select](https://github.com/JedWatson/react-select) for more details on how the `option` type works.

## Available `env` variables

The following variables are available in the `process.env` object:

* `CEREBRO_VERSION` – Version of Cerebro