diff --git a/lib/hooks/moduleloader/index.js b/lib/hooks/moduleloader/index.js index 16696367c..ef82ee43e 100644 --- a/lib/hooks/moduleloader/index.js +++ b/lib/hooks/moduleloader/index.js @@ -53,6 +53,22 @@ module.exports = function(sails) { } } + // Enable server-side LiveScript support + try { + require('LiveScript'); + } catch(e0){ + try { + var appPath = config.appPath || process.cwd(); + require(path.join(appPath, 'node_modules/LiveScript/index')); + } + catch (e1) { + sails.log.verbose('Please run `npm install LiveScript` to use LiveScript (skipping for now)'); + sails.log.silly('Here\'s the require error(s): ',e0,e1); + } + } + + + return { // The path to the application @@ -163,9 +179,9 @@ module.exports = function(sails) { // console.log('TRYING T LOAD CONFIG AT:',sails.config.paths.config); buildDictionary.aggregate({ dirname : sails.config.paths.config || sails.config.appPath + '/config', - exclude : ['locales', 'local.js', 'local.json', 'local.coffee', 'local.litcoffee'], + exclude : ['locales', 'local.js', 'local.json', 'local.coffee', 'local.litcoffee', 'local.ls'], excludeDirs: /(locales|env)$/, - filter : /(.+)\.(js|json|coffee|litcoffee)$/, + filter : /(.+)\.(js|json|coffee|litcoffee|ls)$/, flattenDirectories: !(sails.config.dontFlattenConfig), identity : false }, cb); @@ -175,7 +191,7 @@ module.exports = function(sails) { 'config/local' : function loadLocalOverrideFile (cb) { buildDictionary.aggregate({ dirname : sails.config.paths.config || sails.config.appPath + '/config', - filter : /local\.(js|json|coffee|litcoffee)$/, + filter : /local\.(js|json|coffee|litcoffee|ls)$/, identity : false }, cb); }, @@ -188,7 +204,7 @@ module.exports = function(sails) { var env = sails.config.environment || async_data['config/local'].environment || 'development'; buildDictionary.aggregate({ dirname : (sails.config.paths.config || sails.config.appPath + '/config') + '/env/' + env, - filter : /(.+)\.(js|json|coffee|litcoffee)$/, + filter : /(.+)\.(js|json|coffee|litcoffee|ls)$/, optional : true, flattenDirectories: !(sails.config.dontFlattenConfig), identity : false @@ -203,7 +219,7 @@ module.exports = function(sails) { var env = sails.config.environment || async_data['config/local'].environment || 'development'; buildDictionary.aggregate({ dirname : (sails.config.paths.config || sails.config.appPath + '/config') + '/env', - filter : new RegExp(env + '.(js|json|coffee|litcoffee)$'), + filter : new RegExp(env + '.(js|json|coffee|litcoffee|ls)$'), optional : true, flattenDirectories: !(sails.config.dontFlattenConfig), identity : false @@ -240,7 +256,7 @@ module.exports = function(sails) { loadControllers: function (cb) { buildDictionary.optional({ dirname: sails.config.paths.controllers, - filter: /(.+)Controller\.(js|coffee|litcoffee)$/, + filter: /(.+)Controller\.(js|coffee|litcoffee|ls)$/, flattenDirectories: true, keepDirectoryPath: true, replaceExpr: /Controller/ @@ -259,7 +275,7 @@ module.exports = function(sails) { loadAdapters: function (cb) { buildDictionary.optional({ dirname : sails.config.paths.adapters, - filter : /(.+Adapter)\.(js|coffee|litcoffee)$/, + filter : /(.+Adapter)\.(js|coffee|litcoffee|ls)$/, replaceExpr : /Adapter/, flattenDirectories: true }, bindToSails(cb)); @@ -278,7 +294,7 @@ module.exports = function(sails) { // Get the main model files buildDictionary.optional({ dirname : sails.config.paths.models, - filter : /^([^.]+)\.(js|coffee|litcoffee)$/, + filter : /^([^.]+)\.(js|coffee|litcoffee|ls)$/, replaceExpr : /^.*\//, flattenDirectories: true }, function(err, models) { @@ -309,7 +325,7 @@ module.exports = function(sails) { loadServices: function (cb) { buildDictionary.optional({ dirname : sails.config.paths.services, - filter : /(.+)\.(js|coffee|litcoffee)$/, + filter : /(.+)\.(js|coffee|litcoffee|ls)$/, depth : 1, caseSensitive : true }, bindToSails(cb)); @@ -343,7 +359,7 @@ module.exports = function(sails) { loadPolicies: function (cb) { buildDictionary.optional({ dirname: sails.config.paths.policies, - filter: /(.+)\.(js|coffee|litcoffee)$/, + filter: /(.+)\.(js|coffee|litcoffee|ls)$/, replaceExpr: null, flattenDirectories: true, keepDirectoryPath: true @@ -365,7 +381,7 @@ module.exports = function(sails) { hooksFolder: function(cb) { buildDictionary.optional({ dirname: sails.config.paths.hooks, - filter: /^(.+)\.(js|coffee|litcoffee)$/, + filter: /^(.+)\.(js|coffee|litcoffee|ls)$/, // Hooks should be defined as either single files as a function // OR (better yet) a subfolder with an index.js file @@ -459,7 +475,7 @@ module.exports = function(sails) { loadBlueprints: function (cb) { buildDictionary.optional({ dirname: sails.config.paths.blueprints, - filter: /(.+)\.(js|coffee|litcoffee)$/, + filter: /(.+)\.(js|coffee|litcoffee|ls)$/, useGlobalIdForKeyName: true }, cb); }, @@ -475,7 +491,7 @@ module.exports = function(sails) { loadResponses: function (cb) { buildDictionary.optional({ dirname: sails.config.paths.responses, - filter: /(.+)\.(js|coffee|litcoffee)$/, + filter: /(.+)\.(js|coffee|litcoffee|ls)$/, useGlobalIdForKeyName: true }, bindToSails(cb)); },