Skip to content

Commit

Permalink
Add LiveScript support
Browse files Browse the repository at this point in the history
  • Loading branch information
borestad committed Feb 17, 2015
1 parent 00511b4 commit 322f39a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 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
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,22 @@
"waterline": "~0.10.17"
},
"devDependencies": {
"root-require": "~0.2.0",
"checksum": "~0.1.1",
"request": "*",
"istanbul": "*",
"wrench": "~1.5.1",
"LiveScript": "^1.3.1",
"benchmark": "~1.0.0",
"microtime": "~0.6.0",
"checksum": "~0.1.1",
"coffee-script": "~1.7.1",
"colors": "~0.6.2",
"expect.js": "~0.2.0",
"should": "~2.1.1",
"supertest": "~0.8.2",
"istanbul": "*",
"microtime": "~0.6.0",
"mocha": "~1.17.1",
"portfinder": "~0.2.1",
"coffee-script": "~1.7.1",
"socket.io-client": "^1.2.1"
"request": "*",
"root-require": "~0.2.0",
"should": "~2.1.1",
"socket.io-client": "^1.2.1",
"supertest": "~0.8.2",
"wrench": "~1.5.1"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 322f39a

Please sign in to comment.