3.0.0 • Published 3 years ago

spawn-auto-restart v3.0.0

Weekly downloads
325
License
-
Repository
github
Last release
3 years ago

spawn auto restart

Important: Use it for dev only!

It executes a command through spawn and restart the process in case any change has been detected or the child process has crashed.

Installation

Install via npm:

$ npm install spawn-auto-restart

Usage

require('spawn-auto-restart')({
  proc: 'executable path',
  watch: __dirname
});

To enable logs set an environment variable like this:

DEBUG=spawn-auto-restart

advanced args options

require('spawn-auto-restart')({
  proc: {
    command: 'executable path',
    // ... any spawn argument
    args: ['--dev'],
    cwd: __dirname
  },
  watch: {
    path: 'file, dir, glob, or array',
    // ... any chokidar argument
    ignored: /[\/\\]\./,
    persistent: true
  }
});

Example

Auto restarting an electron app in development when changes have been applied in the main process.

npm.io

node DEBUG=spawn-auto-restart restart.js

#!/usr/bin/env node

var join = require('path').join;
var electron = require('electron-prebuilt');


var main = join(__dirname, '../src/browser/main.js');
var watch = join(__dirname, '../src/browser');


require('spawn-auto-restart')({
  proc: {
    command: electron,
    args: main
  },
  watch: watch
});

Changelog

Contributing

It is required to use editorconfig.

License

Copyright (c) 2015 Max Claus Nunes. This software is licensed under the MIT License.

3.0.0

3 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago