
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
plugin-discovery
Advanced tools
Discover plugins for your (CLI) tool.
This module will scan locations on the file system in an optimal manner, in search of your plugins.
npm i --save plugin-discovery
This plugin can be used in instance form, or statically, both async (recommended) and sync.
There's an example in the example directory of this project.
const {PluginDiscovery} = require('plugin-discovery');
// Sync
let plugins = PluginDiscovery.discoverSync(config);
// Async
PluginDiscovery.discover(discoveryConfig).then(plugins => {
// Go nuts! :)
})
These options are available to configure.
const configOptions = {
// Prefix of your plugins, e.g. my-prefix-foo
prefix: 'my-prefix',
// Strategy to use for the plugin's key. Read on for the options.
dictionaryKeyStrategy: PluginDiscovery.constants.STRATEGY_PROPERTY,
// Name of the property for strategies PROPERTY and METHOD.
dictionaryKeyProperty: 'name',
// Additional paths to look for plugins
searchPaths: [__dirname + '/custom_path'],
// Discover plugins in the global node_modules directory? (useful for CLI tools!)
discoverGlobal: true,
// Discover plugins in the current working directory?
discoverCwd: true,
// Import plugin based on named export? (e.g. module.exports.MyPlugin)
importNamed: 'MyPlugin',
// Import plugin based on named fallback export when not found after regular checks?
namedFallback: 'MyPluginFallback',
// Custom configurers. The key is used to allow for multiple configurers.
configurers: {
myPlugin: (key, plugin, rootImport) => {
// Configure for your own project here...
}
},
// Internal method used to configure. Only override when you really know what you're doing.
configure: (dictionaryKey, imported, root) => this.configure(dictionaryKey, imported, root)
};
There are a couple of strategies available for determining what the key of your plugin will be in the produced plugin-dictionary.
All constants are available through: PluginDiscovery.constants.${constant}
Using this strategy, the key will simply be the entire module name, including the prefix.
Using this strategy, the key will simply be the entire module name, minus the prefix.
This strategy allows you to export the key of the plugin, in the plugin.
module.exports = {
name : 'my_plugin',
plugin: MyPlugin
};
Note: this option requires you to also configure the dictionaryKeyProperty.
This strategy allows you to export the key of the plugin, using a method on the plugin export.
module.exports = {
name : () => 'my_plugin',
plugin: MyPlugin
};
Note: this option requires you to also configure the dictionaryKeyProperty.
This strategy means that PluginDiscovery won't index your plugins at all. Instead, you are expected to do so yourself in the configure phase.
MIT
FAQs
Discover plugins for your (CLI) tool.
We found that plugin-discovery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.