Overriding Scripts

By understanding where Spice looks for modules, you can if you wish override core modules to provide your own custom functionality.

By default Spice will search Support/Library in these paths in order:

  • ~/Library/Application Support/Espresso/
  • MySugar.sugar (if the action is defined in a sugar)
  • Spice.sugar

If you specify new search paths via the filePaths parameter of require(), Spice will instead check all of the paths you specify (in order) in the above locations (in order).

So, for instance, require('module', ['Scripts', 'Library']) causes Spice to check in these places:

  • ~/Library/Application Support/Espresso/Support/Scripts/module.js
  • ~/Library/Application Support/Espresso/Support/Library/module.js
  • MySugar.sugar/Support/Scripts/module.js
  • MySugar.sugar/Support/Library/module.js
  • Spice.sugar/Support/Scripts/module.js
  • Spice.sugar/Support/Library/module.js

As soon as Spice finds a file that matches the name/paths, it will load it, allowing you to override core functionality by including identically named files further up the path tree.