Skip to content

Commit

Permalink
Require Electron 4 and rename enabled option to isEnabled (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus authored May 10, 2019
1 parent 6d310df commit 658da96
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ declare namespace electronDebug {
/**
Default: [Only in development](https://github.com/sindresorhus/electron-is-dev)
*/
readonly enabled?: boolean;
readonly isEnabled?: boolean;

/**
Show DevTools on each created `BrowserWindow`.
Expand Down
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';
const electron = require('electron');
const {app, BrowserWindow} = require('electron');
const localShortcut = require('electron-localshortcut');
const isDev = require('electron-is-dev');

const {app, BrowserWindow} = electron;
const isMacOS = process.platform === 'darwin';

const devToolsOptions = {};
Expand Down Expand Up @@ -67,13 +66,14 @@ const addExtensionIfInstalled = (name, getPath) => {
};

module.exports = options => {
options = Object.assign({
enabled: null,
options = {
isEnabled: null,
showDevTools: true,
devToolsMode: 'undocked'
}, options);
devToolsMode: 'undocked',
...options
};

if (options.enabled === false || (options.enabled === null && !isDev)) {
if (options.isEnabled === false || (options.isEnabled === null && !isDev)) {
return;
}

Expand All @@ -97,7 +97,9 @@ module.exports = options => {
}
});

app.on('ready', () => {
(async () => {
await app.whenReady();

addExtensionIfInstalled('devtron', name => require(name).path);
addExtensionIfInstalled('electron-react-devtools', name => require(name).path);

Expand All @@ -107,7 +109,7 @@ module.exports = options => {

localShortcut.register('CmdOrCtrl+R', refresh);
localShortcut.register('F5', refresh);
});
})();
};

// TODO: Remove this for the next major release
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {refresh, devTools, openDevTools} from '.';

expectType<void>(
electronDebug({
enabled: true,
isEnabled: true,
showDevTools: true
})
);
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Just install any of these extension and they'll be activated for you:
$ npm install electron-debug
```

*Requires Electron 2.0.0 or later.*
*Requires Electron 4 or later.*

<a href="https://www.patreon.com/sindresorhus">
<img src="https://c5.patreon.com/external/logo/[email protected]" width="160">
Expand All @@ -68,7 +68,7 @@ let win;

## API

Only runs when in [development](https://github.com/sindresorhus/electron-is-dev), unless overridden by the `enabled` option. So no need to guard it for production.
Only runs when in [development](https://github.com/sindresorhus/electron-is-dev), unless overridden by the `isEnabled` option. So no need to guard it for production.

### electronDebug([options])

Expand All @@ -78,7 +78,7 @@ Install keyboard shortcuts and optionally activate DevTools on each created `Bro

Type: `Object`

##### enabled
##### isEnabled

Type: `boolean`

Expand Down

0 comments on commit 658da96

Please sign in to comment.