Skip to content

Commit

Permalink
fix(config): policyFactories wasn't using appPath
Browse files Browse the repository at this point in the history
fixes: #2 #3
  • Loading branch information
mastilver committed Jul 22, 2015
1 parent 1ba3599 commit 8e0163c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
18 changes: 14 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
var path = require('path');

var esprima = require('esprima');
var _ = require('lodash');



module.exports = function(sails){
return {

defaults: {
paths: {
policyFactories: '/api/policyFactories',
}
defaults: function(config){
return {
paths: {
policyFactories: path.resolve(config.appPath, 'api/policyFactories')
}
};
},

configure: function(){

_.extend(sails.config.paths, {
policyFactories: path.resolve(sails.config.appPath, sails.config.paths.policyFactories),
});

sails.config.policies = this.parsePolicies(sails.config.policies);
},

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sails-hook-parametized-policies",
"version": "0.3.0",
"version": "0.3.1",
"description": "",
"main": "index.js",
"directories": {
Expand Down Expand Up @@ -32,7 +32,8 @@
"isHook": true
},
"dependencies": {
"esprima": "^2.3.0"
"esprima": "^2.3.0",
"lodash": "^3.10.0"
},
"readmeFilename": "README.md"
}
7 changes: 4 additions & 3 deletions test/basicSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ describe('parametized policies hook - basic', function(){
log: {
level: 'error'
},
appPath: __dirname,
paths: {
controllers: __dirname + '/controllers',
policies: __dirname + '/policies',
policyFactories: __dirname + '/policyFactories',
controllers: './controllers',
policies: './policies',
policyFactories: './policyFactories',
},
routes: {
'GET /ok': 'MainController.ok',
Expand Down

0 comments on commit 8e0163c

Please sign in to comment.