Skip to content
Kyle Ross edited this page Jan 13, 2017 · 3 revisions

There were many breaking changes with the release of 2.x, this document to will help you migrate to the new version of ModClean successfully.

ModClean 2.x requires Node v6.9+

Please be aware of the following breaking changes and update accordingly:

ModClean Module

modclean.patterns

The module no longer exports modclean.patterns as a static variable after switching to the new plugins system. If you want to retrieve the full list of patterns (patterns object), you will need to require the patterns plugin(s) you are using. If instantiating the ModClean class, the list of glob patterns being used can be retrieved via property _patterns after the constructor runs.

ModClean Class

Configuration Options

patterns

patterns no longer takes a rule name such as safe, caution, danger or an array of glob patterns. It now takes an array of plugin(s) and rule(s) from those plugins.

If you were using the rules names: You should update them to default:safe, default:caution or default:danger to continue to use the default included rules. If you were using all 3 rules previously, you can now shorthand it to default:*. The patterns option can be a string (single plugin/rule) or an array of strings (multiple plugins/rules).

If you were passing in an array custom glob patterns: Your custom patterns should go into the new configuration option additionalPatterns. If you do not specify any pattern plugins/rules in patterns it will still include default:safe. To disable that functionality, set patterns to an empty array (ex. patterns: []).

ignore

The ignore configuration option has been renamed to ignorePatterns. Update the configuration key name.

process

If you provided a process function, the arguments have changed. Sync functions are determined if the process function has 0 or 1 arguments and async if 2 or more arguments are provided.

If your process function is async: It now takes 2 arguments file and cb, removing the preexisting files argument. If you need to get the list of files to be removed listen to the files event instead.

If your process function is sync: It now must be 0 or 1 arguments file, removing the preexisting files argument. If you need to get the list of files to be removed listen to the files event instead.

Methods

_find()

The internal _find() method no longer takes 2 parameters, only cb now. Previously, the first parameter of _find() was patterns (an array of glob patterns to find). Since moving to pattern plugins, patterns are now loaded and compiled to instance variable _patterns and _find() uses that internally.

_removeEmpty()

This internal function has been renamed to _removeEmptyDirs() and no longer searches for empty directories, but instead takes a parameter of dirs in which is an array of empty directory paths to be removed. If you want the preexisting functionality, use cleanEmptyDirs() instead.

CLI Changes

Options/Flags

-n, --patterns [list]

This option now takes a list of pattern plugins/rules instead of just a list of rules.

modclean -n default:safe

modclean --patterns="default:safe,default:caution"

-d, --empty

This option has been replaced with -k, --keep-empty and works in reverse of the old functionality.