packages/lambda/src/index.js
function loadNodeModule(nodeModulePath, name) {
  return plugin.myrmex.fire('beforeNodeModuleLoad', nodeModulePath, name)
  .spread((nodeModulePath, name) => {
    let packageJson = {};
    try {
      packageJson = _.cloneDeep(require(path.join(nodeModulePath, 'package.json')));
    } catch (e) {
      if (e.code !== 'MODULE_NOT_FOUND') {
        throw e;
      }
    }

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./node-module
    const NodeModule = require('./node-module');
    const nodePackage = new NodeModule(packageJson, name, nodeModulePath);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterNodeModuleLoad', nodePackage);
  })
  .spread(nodePackage => {
    return Promise.resolve(nodePackage);
  });
}
function loadNodeModule(nodeModulePath, name) {
  return plugin.myrmex.fire('beforeNodeModuleLoad', nodeModulePath, name)
  .spread((nodeModulePath, name) => {
    let packageJson = {};
    try {
      packageJson = _.cloneDeep(require(path.join(nodeModulePath, 'package.json')));
    } catch (e) {
      if (e.code !== 'MODULE_NOT_FOUND') {
        throw e;
      }
    }

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./node-module
    const NodeModule = require('./node-module');
    const nodePackage = new NodeModule(packageJson, name, nodeModulePath);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterNodeModuleLoad', nodePackage);
  })
  .spread(nodePackage => {
    return Promise.resolve(nodePackage);
  });
}
function loadNodeModule ( nodeModulePath , name ) { return plugin . myrmex . fire ( 'beforeNodeModuleLoad' , nodeModulePath , name ) . spread ( ( nodeModulePath , name ) => { let packageJson = { } ; try { packageJson = _ . cloneDeep ( require ( path . join ( nodeModulePath , 'package.json' ) ) ) ; } catch ( e ) { if ( e . code !== 'MODULE_NOT_FOUND' ) { throw e ; } } // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./node-module const NodeModule = require ( './node-module' ) ; const nodePackage = new NodeModule ( packageJson , name , nodeModulePath ) ; // This event allows to inject code to alter the Lambda configuration return plugin . myrmex . fire ( 'afterNodeModuleLoad' , nodePackage ) ; } ) . spread ( nodePackage => { return Promise . resolve ( nodePackage ) ; } ) ; }
Load a NodeModule object
@param  {string} packageJsonPath - path to the package.json file of the package
@param  {string} name - name of the package
@return {Promise<NodeModule>} - promise of a node packages
Load a NodeModule object