Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LiveScript support #2662

Merged
merged 1 commit into from
Apr 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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