Sails.js - How to change a node.js module used by sails?

I want to write my own ejs-locals node module, but I also want that sails use mine and I don't want to change the sails packages.json.

How can I load, after sails loaded its ejs-locals module, my own module to override it?

If there is a proper way to do this kind of stuff, I would like to know :) Thanks.

I tried to find the answer on the official documentation there: http://sailsjs.org/#/documentation/concepts/extending-sails

But there is nothing about that.


Edit:

I tried to use the fn attribute in the config/views.js but it doesn't work as expected, I've made an example here: https://github.com/Vadorequest/sails-custom-ejs-locals


Final edit:

It works fine with the solution proposed as accepted answer, just make sure to disable the layout or it will mess up your configuration. layout: false

Try to configure you view engine in config/views.js file.

...

ext : 'ejs',
fn: require('ejs-locals')

...

The rigth config is:

view: {
    engine: {
       ext: 'ejs',
       fn: yourfunction
   },
   // need to disabe sails.js default partials feature for dont auto load sails ejs-locals
   partial: false
}