Skip to content

Commit

Permalink
Merge pull request #2662 from borestad/feature/add-livescript-support
Browse files Browse the repository at this point in the history
Added LiveScript support
  • Loading branch information
Travis Webb committed Apr 8, 2015
2 parents 767c692 + a4b6479 commit a26b969
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions lib/hooks/moduleloader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
},
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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/
Expand All @@ -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));
Expand All @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
},
Expand All @@ -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));
},
Expand Down

0 comments on commit a26b969

Please sign in to comment.