-
Notifications
You must be signed in to change notification settings - Fork 13
Custom Pattern Plugins
New in version 2.x, ModClean now supports pattern plugins to allow you to use various sets of patterns, along with custom ones. By default, ModClean comes with modclean-patterns-default preinstalled, but you can install or create your own plugins.
If you would like to use a 3rd party plugin, it's pretty simple to install. If you are using the CLI, the plugin should be installed globally (ex. npm install -g modclean-patterns-pluginname
), otherwise programmatically, install locally (ex. npm install modclean-patterns-pluginname --save
).
(None available yet!)
Creating your own patterns plugin is simple. It's a basic Node Module that must be prefixed with modclean-patterns-
that is published to NPM. The module just needs to export and object that contains the pattern definitions (see modclean-patterns-default for an example).
module.exports = {
$default: 'basic',
// Rule name: basic
basic: {
patterns: [
// ... glob patterns here
],
ignore: [
// ... glob patterns to ignore here
]
},
// Rule name: advanced
advanced: {
patterns: [
// ... glob patterns here
],
ignore: [
// ... glob patterns to ignore here
]
}
};
Each key in the object is a rule name that is an object containing patterns
and ignore
arrays of glob patterns. The patterns
section is glob patterns that will be found and removed and the ignore
section is glob patterns to be ignored. Both keys are required, but can be empty arrays.
An optional configuration parameter $default
can be provided which tells ModClean the default rule to use if the user does not specify. If this is not provided, ModClean will use the first rule key it encounters. Note: Rules starting with $
will be ignored.
If your pattern plugin module name is modclean-patterns-myplugin
, you can then reference the rules using myplugin:basic
, myplugin:advanced
, myplugin:*
, myplugin
and modclean-patterns-myplugin
.
If you've created your own plugin, add it to the list above!
To use certain plugins and rules from within modclean, there is a few ways ModClean will parse what is provided. For the examples below, we are going to use the example plugin above.
Usage: [PLUGIN]:[RULE]
Plugins can be accessed using it's name (ex. myplugin
), the full module name (ex. modclean-patterns-myplugin
) or an absolute path to the plguin (ex. /path/to/modclean-patterns-myplugin
). Each of those variations can also take a rule name that is appended with a colon :
after the plugin name. If a rule name is not provided, it will default to the rule specified in $default
or the first rule pulled from the plugin (this is very unreliable). If you want to use all rules from the plugin, you can set the rule name to *
.
Using Default Rule
myplugin
modclean-patterns-myplugin
/path/to/modclean-patterns-myplugin
Using Specific Rule or Rules
myplugin:basic
myplugin:basic,myplugin:advanced
modclean-patterns-myplugin:advanced
/path/to/modclean-patterns-myplugin:basic
Using all Rules
myplugin:*
modclean-patterns-myplugin:*
/path/to/modclean-patterns-myplugin:*
Information:
Wiki Home
Migrating to 3.x
Migrating to 2.x
Benchmarks
Custom Pattern Plugins
Documentation (v3):
CLI Documentation
API Documentation
Documentation (v2):
CLI Documentation
API Documentation