function build_plugin_names() {
  var args = Norma('{name:s, builtin:s|a?, prefix:s|a?, system:a?}', arguments)

  var name = args.name

  var builtin_list = args.builtin
    ? Array.isArray(args.builtin)
      ? args.builtin
      : [args.builtin]
    : []

  var prefix_list = args.prefix
    ? Array.isArray(args.prefix)
      ? args.prefix
      : [args.prefix]
    : []

  var system_modules = args.system || []

  var plugin_names = []

  // Do the builtins first! But only for the framework module, see above.
  if (!name.match(/^[./]/)) {
    builtin_list.forEach(function (builtin) {
      plugin_names.push({ type: 'builtin', name: builtin + name })
      prefix_list.forEach(function (prefix) {
        plugin_names.push({ type: 'builtin', name: builtin + prefix + name })
      })
    })
  }

  // Try the prefix first - this ensures something like seneca-joi works
  // where there is also a joi module
  prefix_list.forEach(function (prefix) {
    plugin_names.push({ type: 'normal', name: prefix + name })
  })

  // Vanilla require on the plugin name.
  // Common case: the require succeeds on first module parent,
  // because the plugin is an npm module
  // in the code calling the framework.
  // You can't load node system modules as plugins, however.
  if (-1 == system_modules.indexOf(name)) {
    plugin_names.push({ type: 'normal', name: name })
  }

  // OK, probably not an npm module, try locally.
  plugin_names.push({ type: 'normal', name: './' + name })

  prefix_list.forEach(function (prefix) {
    plugin_names.push({ type: 'normal', name: './' + prefix + name })
  })

  return plugin_names
}
// Searches are performed without the prefix first
Searches are performed without the prefix first
Searches are performed without the prefix first
function build_plugin_names() {
  var args = Norma('{name:s, builtin:s|a?, prefix:s|a?, system:a?}', arguments)
  var name = args.name
  var builtin_list = args.builtin
    ? Array.isArray(args.builtin)
      ? args.builtin
      : [args.builtin]
    : []
  var prefix_list = args.prefix
    ? Array.isArray(args.prefix)
      ? args.prefix
      : [args.prefix]
    : []
  var system_modules = args.system || []
  var plugin_names = []
  if (!name.match(/^[./]/)) {
    builtin_list.forEach(function (builtin) {
      plugin_names.push({ type: 'builtin', name: builtin + name })
      prefix_list.forEach(function (prefix) {
        plugin_names.push({ type: 'builtin', name: builtin + prefix + name })
      })
    })
  }
  prefix_list.forEach(function (prefix) {
    plugin_names.push({ type: 'normal', name: prefix + name })
  })
  if (-1 == system_modules.indexOf(name)) {
    plugin_names.push({ type: 'normal', name: name })
  }
  plugin_names.push({ type: 'normal', name: './' + name })
  prefix_list.forEach(function (prefix) {
    plugin_names.push({ type: 'normal', name: './' + prefix + name })
  })
  return plugin_names
}
function build_plugin_names ( ) { var args = Norma ( '{name:s, builtin:s|a?, prefix:s|a?, system:a?}' , arguments ) var name = args . name var builtin_list = args . builtin ? Array . isArray ( args . builtin ) ? args . builtin : [ args . builtin ] : [ ] var prefix_list = args . prefix ? Array . isArray ( args . prefix ) ? args . prefix : [ args . prefix ] : [ ] var system_modules = args . system || [ ] var plugin_names = [ ] if ( ! name . match ( / ^[./] / ) ) { builtin_list . forEach ( function ( builtin ) { plugin_names . push ( { type : 'builtin' , name : builtin + name } ) prefix_list . forEach ( function ( prefix ) { plugin_names . push ( { type : 'builtin' , name : builtin + prefix + name } ) } ) } ) } prefix_list . forEach ( function ( prefix ) { plugin_names . push ( { type : 'normal' , name : prefix + name } ) } ) if ( - 1 == system_modules . indexOf ( name ) ) { plugin_names . push ( { type : 'normal' , name : name } ) } plugin_names . push ( { type : 'normal' , name : './' + name } ) prefix_list . forEach ( function ( prefix ) { plugin_names . push ( { type : 'normal' , name : './' + prefix + name } ) } ) return plugin_names }
Searches are performed without the prefix first
Searches are performed without the prefix first
// Do the builtins first! But only for the framework module, see above. // Try the prefix first - this ensures something like seneca-joi works // where there is also a joi module // Vanilla require on the plugin name. // Common case: the require succeeds on first module parent, // because the plugin is an npm module // in the code calling the framework. // You can't load node system modules as plugins, however. // OK, probably not an npm module, try locally.