Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-is-dev

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-is-dev - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

8

index.d.ts
/**
Check if [Electron](https://electronjs.org) is running in development.
Check if Electron is running in development.

@@ -10,3 +10,3 @@ This package must be used from the Electron main process.

```
import isDev = require('electron-is-dev');
import isDev from 'electron-is-dev';

@@ -20,4 +20,4 @@ if (isDev) {

*/
declare const electronIsDev: boolean;
declare const isDev: boolean;
export = electronIsDev;
export default isDev;

@@ -1,3 +0,2 @@

'use strict';
const electron = require('electron');
import electron from 'electron';

@@ -8,5 +7,8 @@ if (typeof electron === 'string') {

const isEnvSet = 'ELECTRON_IS_DEV' in process.env;
const getFromEnv = Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1;
const {env} = process; // eslint-disable-line n/prefer-global/process
const isEnvSet = 'ELECTRON_IS_DEV' in env;
const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1;
module.exports = isEnvSet ? getFromEnv : !electron.app.isPackaged;
const isDev = isEnvSet ? getFromEnv : !electron.app.isPackaged;
export default isDev;
{
"name": "electron-is-dev",
"version": "2.0.0",
"version": "3.0.0",
"description": "Check if Electron is running in development",

@@ -13,2 +13,10 @@ "license": "MIT",

},
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=18"
},
"scripts": {

@@ -34,5 +42,5 @@ "test": "xo && tsd"

"devDependencies": {
"tsd": "^0.14.0",
"xo": "^0.38.1"
"tsd": "^0.30.3",
"xo": "^0.56.0"
}
}

@@ -11,7 +11,7 @@ # electron-is-dev

```sh
npm install electron-is-dev
```
$ npm install electron-is-dev
```
*Requires Electron 3 or later.*
*Requires Electron 28 or later.*

@@ -21,3 +21,3 @@ ## Usage

```js
const isDev = require('electron-is-dev');
import isDev from 'electron-is-dev';

@@ -33,2 +33,25 @@ if (isDev) {

## FAQ
### How is this different than [`app.isPackaged`](https://www.electronjs.org/docs/api/app#appispackaged-readonly)?
This package existed long before that property. The benefit of this package is that you can override the value using an environment variable.
### How do I use this in the renderer process?
You can use [`contextBridge`](https://www.electronjs.org/docs/latest/api/context-bridge) in the [preload script](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload) to manually expose the variable:
```js
import {contextBridge} from 'electron';
import isDev from 'electron-is-dev';
contextBridge.exposeInMainWorld('isDev', isDev);
```
You can then access it in `globalThis` from the renderer process:
```js
console.log(globalThis.isDev);
```
## Related

@@ -35,0 +58,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc