saviogl / generator-sails-plugin-hook

Yoeman generator to create sails hooks that plugs it self in sails structure
2 stars 0 forks source link

Sails not global, sails is not defined #3

Open jaumard opened 9 years ago

jaumard commented 9 years ago

Hi,

In my projet sails is not set as global. And there is an error under _loadPolicies.js cause it used sails.config.paths.policies but sails is undefined. Is there any way to fix this ?

Thanks

saviogl commented 9 years ago

Hello Jaumard,

Could you give more information regarding your problem?

All I've done to extend sails policies was to override loadPolicies function, to loop through an array of policies path extended by the plugin, but the core of the function remains pretty much the same, and still references "sails.config.paths.policies" as shown below:

    // Original function taken from Sails
    // sails/lib/hooks/moduleloader/index.js - loadPolicies
    /**
     * Load app policies
     *
     * @param {Object} options
     * @param {Function} cb
     */
    loadPolicies: function (cb) {
      buildDictionary.optional({
        dirname: sails.config.paths.policies,
        filter: /(.+)\.(js|coffee|litcoffee)$/,
        replaceExpr: null,
        flattenDirectories: true,
        keepDirectoryPath: true
      }, bindToSails(cb));
    },

So you would be getting this error for any load of sails wouldn't you?

Feel free to fork the repository and send a pull request, it would be highly appreciated.

Thanks