0.1.1 • Published 5 years ago

electron-refresh v0.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

electron-refresh

Just a simple module app to reload content of Your electron app.

Getting Started

To get it working:

  • clone this repository
git clone https://github.com/Marcin-Rogalski/electron-refresh.git
  • install dependencies
cd electron-refresh
npm install

Prerequisites

To use this module You need electron and electron-refresh dependencies in your main package.json file:

cd ..
npm install --save-dev electron ./electron-refresh

Usage

  • first You need to add script to package.json file
...
"scripts": {
    ...
    "electron-refresh": "electron-refresh"
    ...
}
...
  • then you need to import 'useRefresh()' and run it inside your app entry file:
const { useRefresh } = require('electron-refresh');
useRefresh( ?onExit );

(optional) onExit - You can pass your own function, that will be executed when hard-resetting the app. Function must close the app.

Configuration

  • arguments - all arguments passed inside scipt will be passed to electron app
...
"scripts": {
    ...
    "electron-refresh": "electron-refresh --debug -n etc."
    ...
}
...

warning

to keep configuration consistent, use args only to pass render-process relevant variables, to pass app entry point use package.json configuration.

  • package.json - below is a complete list of possible configuration settings
...
"scripts": {
    "test": "echo script successfully invoked!"
}
...
"refresh": {

    // path to electron executable, relative to package.json file
    "electronPath": "./node_modules/electron/dist/electron.exe",

    // app entry point relative to package.json file, defaults to '.'
    "appPath": "./app/main.js",
    
    // if set to 'true' every time windows should reload, whole app is closed and reopend, defaults to false
    "hardReset": true,

    // array of files, dirs or glob to watch for change, default to root directory( folder with package.json file )
    "watch": [ "./app/", "**/*.js" ],

    // array of files, dirs, glob or regex to ignore while watching, defaults to /.*\/node_modules\/.*/
    "ignore": [ "/.*\/ignoreThisFile.js$/", "**/*.jsx" ],

    // array of script names that will be run whenever app reloads or restarts
    "scripts": [ "test" ]
}
...

Built With

  • chokidar - used to watch for file changes
  • colors - used to colorize console messages

License

This project is licensed under the MIT License - see the LICENSE.md file for details