Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

daemon-command-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daemon-command-webpack-plugin

Run or restart npm commands after webpack build has finished

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by900%
Maintainers
1
Weekly downloads
 
Created
Source

daemon-command-webpack-plugin

license travis AppVeyor npm npm

This is simple webpack plugin that monitors webpack events and start or restart npm/yarn command. The main purpose of this plugin is to restart node process when webpack has finised rebuilding the source tree. It is also possible to wait for the marker to make sure the process is finished doing the job (like starting the web server)

Installing as a package

Use NPM: npm i daemon-command-webpack-plugin -D or npm install daemon-command-webpack-plugin --save-dev

Use YARN: yarn add daemon-command-webpack-plugin --dev

Usage

// package.json

{
  "name": "me-app",
  "version": "1.0.0",
  "scripts": {
      "start:dev:env": "node server/build/index.js",
      "start:dev": "NODE_ENV=development PORT=3000 node server/build/index.js",
    },
}
// webpack.config.js

import DaemonCommandPlugin from 'daemon-command-webpack-plugin';

module.exports = {
  // ... rest of config
  plugins: [
    // Command #1
    new DaemonCommandPlugin('start:dev:env', {
      spawn : {
        env : {
          NODE_ENV : 'development',
          PORT : 3000
        }
      }
    }),
    // Command #2
    new DaemonCommandPlugin('start:dev');,
    // Command #3 use yarn
    new DaemonCommandPlugin('start:dev', {
      manager : 'yarn'
    });
  ]
}

Usage with marker

// webpack.config.js

import DaemonCommandPlugin from 'daemon-command-webpack-plugin';

module.exports = {
  // ... rest of config
  plugins: [
    // Command #1
    new DaemonCommandPlugin('start:dev', {
      marker : true
    });
  ]
}
// your-app.js

import express from 'express';
import marker from 'daemon-command-webpack-plugin/marker';

let app = express();

app.listen(8080, () => {
    console.log('Listen port: 8080');
    marker();
    // or
    marker('Listen port: 8080'); // Custom message
})

Arguments

  • command <String> The package.json scripts command to run
  • options <Object>
    • event <String> Webpack life cycle event. Default: after-emit
    • marker <Boolean> Resolve promise when a marker is found to stdout. Default: false
    • spawn <Object> Spawn options
      • cwd <String> Current working directory of the child process
      • env <Object> Environment key-value pairs
      • argv0 <String> Explicitly set the value of argv[0] sent to the child process. This will be set to command if not specified.
      • stdio <Array> | <String> Child's stdio configuration. (See options.stdio)
      • detached <Boolean> Prepare child to run independently of its parent process. Specific behavior depends on the platform, see options.detached)
      • uid <Number> Sets the user identity of the process
      • gid <Number> Sets the group identity of the process
      • shell <Boolean> | <String> If true, runs command inside of a shell. Uses /bin/sh on UNIX, and cmd.exe on Windows. A different shell can be specified as a string. The shell should understand the -c switch on UNIX, or /d /s /c on Windows. Defaults to false (no shell).

Use cwd to specify the working directory from which the process is spawned. If not given, the default is to inherit the current working directory. Use env to specify environment variables that will be visible to the new process, the default is process.env.

Marker arguments

License

MIT

Keywords

FAQs

Package last updated on 11 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc