Skip to content

Commit

Permalink
Do not use process.cwd() to identify app root
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Oct 27, 2012
1 parent 3f3aeef commit 13fce66
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
13 changes: 11 additions & 2 deletions bin/railway
@@ -1,8 +1,17 @@
#!/usr/bin/env node

var sys = require('util');
require('coffee-script');
var app = require(process.cwd() + '/server');
var fs = require('fs');
var srvFile = process.cwd() + '/server';
var app;
if (fs.existsSync(srvFile + '.js')) {
app = require(srvFile);
} else if (fs.existsSync(srvFile + '.coffee')) {
require('coffee-script');
app = require(srvFile);
} else {
app = require('../lib/onrailway').createServer();
}
var railway = app.railway;
var generators = railway.generators;
var tools = railway.tools;
Expand Down
2 changes: 1 addition & 1 deletion lib/onrailway.js
Expand Up @@ -70,7 +70,7 @@ Railway.prototype.version = require('../package').version;
*
*/
exports.init = function initRailway(app) {
app.root = app.root || process.cwd();
app.root = app.root || path.dirname(module.parent.filename);

// create API publishing object
var railway = new Railway(app);
Expand Down
3 changes: 1 addition & 2 deletions templates/config/environment.coffee
@@ -1,13 +1,12 @@
express = require 'express'

app.configure ->
cwd = process.cwd()
PREPEND_MIDDLEWARE
app.set 'view engine', 'VIEWENGINE'
app.set 'view options', complexNames: true
app.enable 'coffee'

app.use express.static(cwd + '/public', maxAge: 86400000)
app.use express.static(app.root + '/public', maxAge: 86400000)
app.use express.bodyParser()
app.use express.cookieParser 'secret'
app.use express.session secret: 'secret'
Expand Down
3 changes: 1 addition & 2 deletions templates/config/environment.js
@@ -1,9 +1,8 @@
var express = require('express');

app.configure(function(){
var cwd = process.cwd();
PREPEND_MIDDLEWARE
app.use(express.static(cwd + '/public', {maxAge: 86400000}));
app.use(express.static(app.root + '/public', {maxAge: 86400000}));
app.set('view engine', 'VIEWENGINE');
app.set('view options', {complexNames: true});
app.set('jsDirectory', '/javascripts/');
Expand Down

0 comments on commit 13fce66

Please sign in to comment.