Skip to content

Commit

Permalink
Switch to using includeAll directly in moduleloader. Also fix typo (e…
Browse files Browse the repository at this point in the history
…xits => exists)
  • Loading branch information
mikermcneil committed Aug 16, 2016
1 parent 5cb9164 commit f6e8d32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
4 changes: 0 additions & 4 deletions REPOS.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@
"repoName": "sails-generate",
"owner": "balderdashy"
},
{
"repoName": "sails-build-dictionary",
"owner": "balderdashy"
},
{
"repoName": "captains-log",
"owner": "balderdashy"
Expand Down
40 changes: 20 additions & 20 deletions lib/hooks/moduleloader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function(sails) {
var async = require('async');
var _ = require('lodash');
var walk = require('walk');
var buildDictionary = require('sails-build-dictionary');
var includeAll = require('include-all');



Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports = function(sails) {

async.auto({
'config/*': function loadOtherConfigFiles (cb) {
buildDictionary.aggregate({
includeAll.aggregate({
dirname : sails.config.paths.config || path.resolve(sails.config.appPath, 'config'),
exclude : ['locales'].concat(_.map(sails.config.moduleloader.configExt, function (extension){ return 'local.'+extension; })),
excludeDirs: /(locales|env)$/,
Expand All @@ -254,7 +254,7 @@ module.exports = function(sails) {
},

'config/local' : function loadLocalOverrideFile (cb) {
buildDictionary.aggregate({
includeAll.aggregate({
dirname : sails.config.paths.config || path.resolve(sails.config.appPath, 'config'),
filter : new RegExp('local\\.(' + sails.config.moduleloader.configExt.join('|') + ')$'),
identity : false
Expand All @@ -267,7 +267,7 @@ module.exports = function(sails) {
// or the command line, so that takes precedence. Otherwise, check the config/local.js file
// for an environment setting. Lastly, default to development.
var env = sails.config.environment || async_data['config/local'].environment || 'development';
buildDictionary.aggregate({
includeAll.aggregate({
dirname : path.resolve( sails.config.paths.config || path.resolve(sails.config.appPath, 'config'), 'env', env ),
filter : new RegExp('(.+)\\.(' + sails.config.moduleloader.configExt.join('|') + ')$'),
optional : true,
Expand All @@ -282,7 +282,7 @@ module.exports = function(sails) {
// or the command line, so that takes precedence. Otherwise, check the config/local.js file
// for an environment setting. Lastly, default to development.
var env = sails.config.environment || async_data['config/local'].environment || 'development';
buildDictionary.aggregate({
includeAll.aggregate({
dirname : path.resolve( sails.config.paths.config || path.resolve(sails.config.appPath, 'config'), 'env' ),
filter : new RegExp('^' + env + '\\.(' + sails.config.moduleloader.configExt.join('|') + ')$'),
optional : true,
Expand Down Expand Up @@ -317,7 +317,7 @@ module.exports = function(sails) {
* @param {Function} cb
*/
loadControllers: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.controllers,
filter: new RegExp('(.+)Controller\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
flattenDirectories: true,
Expand All @@ -332,7 +332,7 @@ module.exports = function(sails) {
* @param {Function} cb
*/
loadAdapters: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.adapters,
filter: new RegExp('(.+Adapter)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
replaceExpr: /Adapter/,
Expand All @@ -348,7 +348,7 @@ module.exports = function(sails) {
*/
loadModels: function (cb) {
// Get the main model files
buildDictionary.optional({
includeAll.optional({
dirname : sails.config.paths.models,
filter : new RegExp('^([^.]+)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
replaceExpr : /^.*\//,
Expand All @@ -357,7 +357,7 @@ module.exports = function(sails) {
if (err) { return cb(err); }

// Get any supplemental files
buildDictionary.optional({
includeAll.optional({
dirname : sails.config.paths.models,
filter : /(.+)\.attributes.json$/,
replaceExpr : /^.*\//,
Expand All @@ -376,7 +376,7 @@ module.exports = function(sails) {
* @param {Function} cb
*/
loadServices: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname : sails.config.paths.services,
filter : new RegExp('(.+)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
depth : 1,
Expand All @@ -391,7 +391,7 @@ module.exports = function(sails) {
* @param {Function} cb
*/
statViews: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.views,
filter: /(.+)\..+$/,
replaceExpr: null,
Expand All @@ -406,7 +406,7 @@ module.exports = function(sails) {
* @param {Function} cb
*/
loadPolicies: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.policies,
filter: new RegExp('(.+)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
replaceExpr: null,
Expand All @@ -426,7 +426,7 @@ module.exports = function(sails) {
async.auto({
// Load apps from the "api/hooks" folder
hooksFolder: function(cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.hooks,
filter: new RegExp('^(.+)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),

Expand All @@ -439,7 +439,7 @@ module.exports = function(sails) {

// Load package.json files from node_modules to check for hooks
nodeModulesFolder: function(cb) {
buildDictionary.optional({
includeAll.optional({
dirname: path.resolve(sails.config.appPath, 'node_modules'),
filter: /^(package\.json)$/,
excludeDirs: /^\./,
Expand Down Expand Up @@ -584,7 +584,7 @@ module.exports = function(sails) {
* @param {Function} cb
*/
loadBlueprints: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.blueprints,
filter: new RegExp('(.+)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
useGlobalIdForKeyName: true
Expand All @@ -598,17 +598,17 @@ module.exports = function(sails) {
* @param {Function} cb
*/
loadResponses: function (cb) {
buildDictionary.optional({
includeAll.optional({
dirname: sails.config.paths.responses,
filter: new RegExp('(.+)\\.(' + sails.config.moduleloader.sourceExt.join('|') + ')$'),
useGlobalIdForKeyName: true
}, bindToSails(cb));
},

optional: buildDictionary.optional,
required: buildDictionary.required,
aggregate: buildDictionary.aggregate,
exits: buildDictionary.exists
optional: includeAll.optional,
required: includeAll.required,
aggregate: includeAll.aggregate,
exists: includeAll.exists
};


Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"grunt-sails-linker": "~0.10.1",
"grunt-sync": "0.5.2",
"i18n": "0.8.1",
"include-all": "~0.1.6",
"include-all": "^1.0.0",
"lodash": "3.10.1",
"lodash.isarray": "3.0.4",
"lodash.iserror": "3.1.1",
Expand All @@ -82,7 +82,6 @@
"rc": "1.0.1",
"reportback": "~0.1.9",
"rttc": "9.3.3",
"sails-build-dictionary": "~0.10.1",
"sails-disk": "~0.10.9",
"sails-generate": "~0.13.0",
"sails-hook-orm": "~1.0.6",
Expand Down

0 comments on commit f6e8d32

Please sign in to comment.