Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added debug switch.

  • Loading branch information...
commit 2f2ef47cb6ba048532225468dba38e0c8a128fec 1 parent 9c99c52
@jwall authored
View
8 lib/controller.js
@@ -444,8 +444,12 @@ exports.addBasePath = function (basePath, prefix, context) {
var stat = fs.statSync(path.join(basePath, file));
if (stat.isFile()) {
// @todo make a switch for this
- //var m = file.match(/(.*?)_controller\.(js|coffee)$/);
- var m = file.match(/(.*?)_controller\.(js)$/);
+ var m = null;
+ if (railway.debug == true) {
+ m = file.match(/(.*?)_controller\.(js)$/);
+ } else {
+ m = file.match(/(.*?)_controller\.(js|coffee)$/);
+ }
if (m) {
var ctl = prefix + m[1];
Controller.index[ctl] = Controller.index[ctl] || path.join(basePath, file);
View
9 lib/models.js
@@ -199,8 +199,13 @@ exports.loadModels = function (cb) {
if (path.existsSync(modelsDir)) {
fs.readdirSync(modelsDir).forEach(function (file) {
// @todo make a switch for this
- // if (file.match(/^[^\.].*?\.(js|coffee)$/)) {
- if (file.match(/^[^\.].*?\.(js)$/)) {
+ var m = null;
+ if (railway.debug == true) {
+ m = file.match(/^[^\.].*?\.(js)$/);
+ } else {
+ m = file.match(/^[^\.].*?\.(js|coffee)$/);
+ }
+ if (m) {
var filename = modelsDir + file;
runCode(filename, ctx);
}
View
23 lib/onrailway.js
@@ -34,9 +34,9 @@ try {
}
}catch(e){}
-exports.init = function (app) {
+exports.init = function (app, debug) {
if (arguments.length == 2) {
- app = arguments[1];
+ app = arguments[0];
}
// globalize app object
@@ -46,6 +46,12 @@ exports.init = function (app) {
// create API publishing object
new Railway();
+ railway.debug = debug;
+ if (debug == true) {
+ console.log("Debug mode enabled.");
+ }
+
+
// run environment.{js|coffee} and environments/{test|development|production}.{js|coffee}
configureApp();
@@ -85,6 +91,9 @@ exports.init = function (app) {
exports.createServer = function (options) {
options = options || {};
+ var debug;
+ debug = typeof options.debug !== "undefined" && options.debug !== null ? options.debug : false;
+
var keys, app,
key = options.key || process.cwd() + '/config/tsl.key',
cert = options.cert || process.cwd() + '/config/tsl.cert';
@@ -102,7 +111,7 @@ exports.createServer = function (options) {
app = require('express').createServer();
}
- exports.init(app);
+ exports.init(app, debug);
return app;
};
@@ -185,8 +194,12 @@ function loadObservers() {
if (!err && files) {
files.forEach(function (file) {
// @todo make a switch for this
- // if (file.match(/^[^\.]/)) {
- var m = file.match(/(^[^\.]*).js$/);
+ var m = null;
+ if (railway.debug == true) {
+ m = file.match(/(^[^\.]*).js$/);
+ } else {
+ m = file.match(/^[^\.]/);
+ }
if (m) {
require(path.join(dir, file));
}
View
9 lib/railway_utils.js
@@ -120,9 +120,12 @@ var scriptCache = {};
function runCode(filename, context) {
// @todo make a switch for this
- //var isCoffee = filename.match(/coffee$/);
- var isCoffee = false;
-
+ var isCoffee = null;
+ if (railway.debug == true) {
+ isCoffee = false;
+ } else {
+ isCoffee = filename.match(/coffee$/);
+ }
context = context || {};
var dirname = path.dirname(filename);
Please sign in to comment.
Something went wrong with that request. Please try again.