GithubHelp home page GithubHelp logo

iceend / electron-watch Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 14 KB

Automatically restart Electron app when the main process files are changed.

License: MIT License

JavaScript 100.00%
electron electron-watch auto-reload

electron-watch's Introduction

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

electron-watch's People

Contributors

iceend avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ryanaltair

electron-watch's Issues

Error (should we have some sort of babel setup?)

Uncaught Exception:
Error: Cannot find module 'babel-register'
    at Module._resolveFilename (internal/modules/cjs/loader.js:584:15)
    at Function.Module._resolveFilename (/Users/tyler/jolt/code/blackjack/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/common/reset-search-paths.js:43:12)
    at Function.Module._load (internal/modules/cjs/loader.js:510:25)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at Function.Module._preloadModules (internal/modules/cjs/loader.js:809:12)
    at Object.<anonymous> (/Users/tyler/jolt/code/blackjack/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:74:10)
    at Object.<anonymous> (/Users/tyler/jolt/code/blackjack/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:204:3)
    at Module._compile (internal/modules/cjs/loader.js:693:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
    at Module.load (internal/modules/cjs/loader.js:602:32)

NPM warned me about "low severity vulnerability" when I installed electron-watch

Problem couldn't be resolved with "npm audit fix"
My os: {"os":"win32","arch":"x64"}

                   === npm audit security report ===                         
                                                              
                             Manual Review                                  
         Some vulnerabilities require your attention to resolve             
                                                                            
      Visit https://go.npm.me/audit-guide for additional guidance           

Low Regular Expression Denial of Service

Package braces

Patched in >=2.3.1

Dependency of electron-watch [dev]

Path electron-watch > chokidar > anymatch > micromatch > braces

More info https://npmjs.com/advisories/786

found 1 low severity vulnerability in 1583 scanned packages
1 vulnerability requires manual review. See the full report for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.