Skip to content

Commit

Permalink
fix(handlers): Relative path when structure not flat
Browse files Browse the repository at this point in the history
When the handlers directory structure is not flat, the relative path to
the models directory will vary so instead of assuming that it is flat
leverage the actual path of the handler to determine relative path
to specific database model module.
  • Loading branch information
kenjones-cisco committed Jan 6, 2016
1 parent b4b55c8 commit 908d59c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = yeoman.Base.extend({

// provides access to lodash within the template
route._ = _;
route.dbmodels = self._getDbModels(route);
route.dbmodels = self._getDbModels(route, path.dirname(file));
if (!self.options['dry-run']) {
self.template('_handler.js', file, route);
} else {
Expand Down Expand Up @@ -203,10 +203,9 @@ module.exports = yeoman.Base.extend({
}
},

_getDbModels: function getDbModels(route) {
_getDbModels: function getDbModels(route, relPath) {
var self = this;
var dbModels = [];
var relPath = upath.joinSafe(self.appRoot, 'handlers');
var single, dbFileName, className;

if (!self.config.get('database')) {
Expand Down

0 comments on commit 908d59c

Please sign in to comment.