Skip to content

MMRIZE/MMM-ModuleMonkeyPatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMM-ModuleMonkeyPatch

MagicMirror module to make monkeypatching other module.

Installation

cd <MAGICMIRROR DIRECTORY>/modules
git clone https://github.com/MMRIZE/MMM-ModuleMonkeyPatch

Configuration

{
  module: "MMM-ModuleMonkeyPatch",
  config: {
    patches: [
      {
        module: "MMM-Something",
        method: "getDom", // Or Whatever method that module has.
        patch: function (original, args) {
          console.log('patch-start')
          let ret = original(args) // Or do something by yourself
          console.log('patch-end')
          return ret // return expected return of origianl method.
        }
      }, // You can add more patches.
    ]
  }

This will replace original method of the module with patch function.

patch function would be bound to the original module, so you can use this context in the function.

Why?

When you need some modification of existing modules, but do not want to edit the original source code to prevent conflicts on upgrade/update.

But.. I think rare people will use this module. :D. This was my half-day weekend killing-time project.

Limitation

  • This module works after ALL_MODULES_STARTED notfication, that means you cannot override start method.

History

1.0.0 (2023-07-29)

  • Released.

Author

ko-fi

About

MagicMirror module to make monkeypatching for other module.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published