Skip to content

Commit

Permalink
Support modular railway
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed May 2, 2012
1 parent 7d748e9 commit 2b67400
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ exports.Schema = require('./lib/schema').Schema;
exports.AbstractClass = require('./lib/abstract-class').AbstractClass;
exports.Validatable = require('./lib/validatable').Validatable;

exports.init = function () {
exports.init = function (root) {
if (!global.railway) return;
railway.orm = exports;
require('./lib/railway');
require('./lib/railway')(root);
};

try {
Expand Down
8 changes: 6 additions & 2 deletions lib/railway.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ var Schema = railway.orm.Schema;

railway.orm._schemas = [];

var confFile = app.root + '/config/database.json';
module.exports = function init(root) {

var confFile = (root || app.root) + '/config/database.json';
var config;

if (path.existsSync(confFile)) {
Expand All @@ -25,7 +27,7 @@ railway.orm._schemas.push(schema);
context = prepareContext(schema);

// run schema first
var schemaFile = app.root + '/db/schema.';
var schemaFile = (root || app.root) + '/db/schema.';
if (path.existsSync(schemaFile + 'js')) {
schemaFile += 'js';
} else if (path.existsSync(schemaFile + 'coffee')) {
Expand Down Expand Up @@ -173,3 +175,5 @@ function prepareContext(defSchema, done) {
return r;
}
}

};

0 comments on commit 2b67400

Please sign in to comment.