• Stars
    star
    121
  • Rank 284,743 (Top 6 %)
  • Language
    JavaScript
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ–₯ run, watch, and restart electron apps using magic

electronmon

electronmon logo

Watch and reload your electron app the easy way!

GitHub Actions CI npm-downloads npm-version

This is the simplest way to watch and restart/reload electron applications. It requires no quessing, no configuration, and no changing your application or conditionally requiring dependencies. And best of all, it keeps everything in-process, and will not exit on the first application relaunch.

It was inspired by nodemon and largely works the same way (by magic πŸ§™).

To use it, you don't have to change your application at all. Just use electronmon instead of electron to launch your application, using all the same arguments you would pass to the electron cli:

npx electronmon .

That's it! Now, all your files are watched. Changes to main process files will cause the application to restart entirely, while changes to any of the renderer process files will simply reload the application browser windows.

All you have to do now is write your application code.

Configuration

Okay, okay... so it's not exactly magic. While electronmon will usually work exactly the way you want it to, you might find a need to contigure it. You can do so by providing extra values in your package.json in the an electronmon object. The following options are available:

  • patterns {Array<String>} - Additional patterns to watch, in glob form. The default patterns are ['**/*', '!node_modules', '!node_modules/**/*', '!.*', '!**/*.map'], and this property will add to that. If you want to ignore some files, start the glob with !.

Example:

{
  "electronmon": {
    "patterns": ["!test/**"]
  }
}

Supported environments

This module is tested and supported on Windows, MacOS, and Linux, using node versions 10 - 18 and electron versions 8 - 23. Considering it still works after all these versions, there's a good chance it works with newer versions as well.

API Usage

You will likely never need to use this, but in case you do, this module can be required and exposes and API for interacting with the monitor process.

const electronmon = require('electronmon');

(async () => {
  const options = {...};
  const app = await electronmon(options);
})();

All options are optional with reasonable defaults (again, magic πŸ§™), but the following options are available:

  • cwd {String} - The root directory of your application.
  • args {Array<String>} - The arguments that you want to pass to electron.
  • env {Object} - Any additional environment variables you would like to specically provide to your electron process.
  • patterns {Array<String>} - Additional patterns to watch, in glob form. The default patterns are ['**/*', '!node_modules', '!node_modules/**/*', '!.*', '!**/*.map'], and this property will add to that. If you want to ignore some files, start the glob with !.
  • logLevel {String} - The level of logging you would like. Possible values are verbose, info, error, and quiet.
  • electronPath {String} - The path to the electron binary.

When the monitor is started, it will start your application and the monitoring process. It exposes the following methods for interacting with the monitoring process (all methods are asynchronous and return a Promise):

  • app.reload() β†’ Promise - reloads all open web views of your application
  • app.restart() β†’ Promise - restarts the entire electron process of your application
  • app.close() β†’ Promise - closes the entire electron process of your application and waits for file changes in order to restart it
  • app.destroy() β†’ Promise - closes the entire electron process and stops monitoring

More Repositories

1

canvas-confetti

πŸŽ‰ performant confetti animation in the browser
JavaScript
6,673
star
2

raw-viewer

πŸ“· raw image viewer
JavaScript
44
star
3

mock-stdio

πŸ”‡ mock stdio output for tests
JavaScript
23
star
4

tiny.toast

🍞 minimal code for tiny notifications
JavaScript
21
star
5

grandma

πŸ‘΅ fully programmable stress testing framework
JavaScript
20
star
6

svg-app-icon

🎨 create high-quality desktop icons from svg source
JavaScript
15
star
7

fork-ribbon-css-builder

πŸŽ€ pure CSS "For me on GitHub" ribbon generator
CSS
14
star
8

css-raw-loader

🌁 CSS Raw loader module for Webpack
JavaScript
13
star
9

unofficial-hipchat

πŸ’ˆ a hipper chat
JavaScript
11
star
10

github-emoji-cheatsheet

🍍 all the emoji as rendered by GitHub
JavaScript
9
star
11

ColorJS

✏️ convert and calculate colors in JavaScript
JavaScript
8
star
12

puptron

🐢 automate your Electron application with Puppeteer
JavaScript
8
star
13

electron-template

βš› opinionated electron application template
JavaScript
8
star
14

friendlyCast

A developer-friendly wrapper for the Chromecast API
JavaScript
8
star
15

watchboy

⌚ watch for file changes without the hassle
JavaScript
7
star
16

video-tools

🎬 cli tool for video processing
JavaScript
7
star
17

tiny.request

πŸ— Node.JS-style ajax requests for the browser
JavaScript
6
star
18

gulp-each

πŸ“‡ a for-each that provides the raw file content
JavaScript
6
star
19

chord-explorer

🎸 look up guitar and ukulele chords
JavaScript
3
star
20

video-tools-app

🎬 gui tool for video processing
JavaScript
3
star
21

mocha-slow-test-reporter

βŒ› list slow mocha tests
JavaScript
3
star
22

shellton

🐚 execute other stuff from node
JavaScript
2
star
23

fair-compare

🎑 simple and easy comparison of images and text across whole directories
JavaScript
2
star
24

fs-watch-file

πŸ—ƒ watch specific files for changes
JavaScript
2
star
25

glob-filestream

πŸ“„ read a glob of files into a single stream
JavaScript
2
star
26

PointBank

Research software for geocoded location and analysis of tweets.
JavaScript
2
star
27

multispawn

β›“ run multiple processes in the foreground
JavaScript
2
star
28

localcast

πŸ“Ί send local videos to Chromecast - but maybe don't use it
JavaScript
2
star
29

gulp-multistream

πŸ’¦ write data to multiple streams in the pipeline, at the same time.
JavaScript
2
star
30

json-cli-toolkit

πŸ™‰ work with json from the command line
JavaScript
2
star
31

repeatspawn

πŸ” execute a cli command repeatedly until it fails
JavaScript
1
star
32

read-vinyl-file-stream

πŸ“‡ iterate a vinyl file stream with minimal code
JavaScript
1
star
33

brackets-theme-one-gray

🍹 the dark Brackets theme
HTML
1
star
34

node-generate-readme-badges

πŸ“› just being lazy/smort
JavaScript
1
star
35

unstyle

βœ‚οΈ unstyle CLI output
JavaScript
1
star
36

node--proxy

a super simple proxy for when you need one in a pinch
JavaScript
1
star
37

brackets-shebang-highligher

πŸ’’ i don't want to click buttons, you figure it out
JavaScript
1
star
38

dcrawr

😺 dcraw with a little added r
JavaScript
1
star
39

jsForm

Easily create, validate, and submit forms
JavaScript
1
star
40

mocha-duplicate-reporter

Finds mocha tests that use the exact same full name
JavaScript
1
star
41

eol-fix-stream

πŸ”° end all the things with lf
JavaScript
1
star
42

tiny.cdn

πŸ‘€ my libraries, hosted
HTML
1
star
43

stack-source-mapper

🎰 decode a minified stacktrace using the source maps
JavaScript
1
star
44

runtime-required

πŸ“’ get notified when a file is required
JavaScript
1
star
45

wait-for-throwable

🧨 utility to retry an erroring function until it succeeds
JavaScript
1
star