node-dev icon indicating copy to clipboard operation
node-dev copied to clipboard

API

Open jonathanong opened this issue 9 years ago • 5 comments

would be nice if there were an API. i'd like to embed a server within a server and have the sub app automatically restart itself

jonathanong avatar Jun 26 '16 06:06 jonathanong

It's undocumented, but you can already do the following:

const nodeDev = require('node-dev');
nodeDev(script, scriptArgs, nodeArgs, opts);

Would this work for you?

fgnass avatar Jun 29 '16 07:06 fgnass

yep, i just don't know what those arguments are :P all i need are docs or comments!

jonathanong avatar Jun 29 '16 07:06 jonathanong

nodeDev(
  '/some/script.js', // the script to run
  ['--foo', '-bar'], // command line arguments to pass to the script
  ['--debug'],       // arguments to pass to the node binary
  {
    notify: false,   // whether to use desktop notifications
    deps: true,      // whether to watch files in node_modules too
    allDeps: false,  // whether to watch transitive deps (deps of deps) too
    dedupe: false,   // whether to use https://github.com/thlorenz/dynamic-dedupe
    respawn: false,  // whether to keep watching for changes after the script has exited
    poll: false,     // whether to force polling for file changes
  }
);

fgnass avatar Jun 29 '16 08:06 fgnass

Are those the defaults you listed?

Sawtaytoes avatar Feb 26 '18 05:02 Sawtaytoes

@fgnass hi, if i use nodeDev(script, scriptArgs, nodeArgs, opts);, could I got some callback event when code restart?

chhpt avatar Mar 11 '21 12:03 chhpt