Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

electron-watch

1.0.9 • Public • Published

electron-watch

Automatically restart Electron app when the main process file is changed.

npm MIT License

Installation

npm install electron-watch

Usage

For example,

package.json:

{
  //...
  "scripts": {
    "dev:electron-main": "cross-env NODE_ENV='development' electron -r babel-register ./app/renderer/",
  },
  //...
}
 

Adding code block to the main process file:

index.js:

import electron from 'electron';
import path from 'path';
 
if (process.env.NODE_ENV === 'development') {
  require('electron-watch')(
    __dirname,
    'dev:electron-main',             // npm scripts, means: npm run dev:electron-main
    path.join(__dirname, './'),      // cwd
    2000,                            // debounce delay
  );
}

OPTIONS

field type description
path string Paths to files, dirs to be watched recursively, or glob patterns.
command string npm script name, use this to start electron main process
cwd string Current working directory of the child process.
delay Number Delay (in ms) arguments of debounce, default is 3000ms

LICENSE

MIT @ Alchemy

install

npm i electron-watch

Downloadsweekly downloads

10

version

1.0.9

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability