src/plugin.js
function NpmSubmodulePlugin(options) {
  // initialize instance variables
  this.commands = options.commands ? options.commands : [];
  this.autoInstall = options.autoInstall ? options.autoInstall : false;
  this.logger = options.logger ? options.logger : console.log;
  this.path = 'node_modules' + path.sep + options.module;
  this.spawnSyncOptions = {
    stdio: ['ignore', 'pipe', 'inherit'],
    cwd: this.path
  };
}
function NpmSubmodulePlugin(options) {
  // initialize instance variables
  this.commands = options.commands ? options.commands : [];
  this.autoInstall = options.autoInstall ? options.autoInstall : false;
  this.logger = options.logger ? options.logger : console.log;
  this.path = 'node_modules' + path.sep + options.module;
  this.spawnSyncOptions = {
    stdio: ['ignore', 'pipe', 'inherit'],
    cwd: this.path
  };
}
function NpmSubmodulePlugin ( options ) { // initialize instance variables this . commands = options . commands ? options . commands : [ ] ; this . autoInstall = options . autoInstall ? options . autoInstall : false ; this . logger = options . logger ? options . logger : console . log ; this . path = 'node_modules' + path . sep + options . module ; this . spawnSyncOptions = { stdio : [ 'ignore' , 'pipe' , 'inherit' ] , cwd : this . path } ; }
Logger to caputer the command output.
@callback Logger
@param {string} message - message to log.
 
The mandatory named JavaScript function which represents a Webpack plugin.
@example
new NpmSubmodulePlugin({
module: 'isObject',
autoInstall: false,
commands: [
'install',
'install --save react'
],
logger: console.log
});
@param {Object} options - The plugin options
@param {string} options.module - The node module to operate on.
@param {boolean} [options.autoInstall=false] - Adds `npm install` to the commands if the `node_modules` folder is not exists.
@param {string[]} [options.commands=[]] - The commands to execute.
@param {Logger} [options.logger=console.log] - The logger.
@class
Logger to caputer the command output .