Permalink
Browse files

existsSync changes for Node 0.8 compat.

  • Loading branch information...
1 parent 118d00f commit de86f044c5aac1a02617ea87505728ecca1c0aac mde committed Jun 27, 2012
Showing with 22 additions and 13 deletions.
  1. +4 −1 bin/cli.js
  2. +12 −10 lib/app.js
  3. +3 −1 lib/cluster/master.js
  4. +3 −1 lib/init/i18n.js
View
@@ -4,6 +4,7 @@
var geddy = require('../lib/geddy');
var exec = require('child_process').exec
+ , fs = require('fs')
, path = require('path')
, parseopts = require('../lib/parseopts')
, utils = require('../lib/utils/index')
@@ -135,7 +136,9 @@ else {
// Just `geddy` -- start the server
else {
var configPath = path.join(cwd, 'config')
- , geddyApp = path.existsSync(configPath);
+ , existsSync = typeof fs.existsSync == 'function' ?
+ fs.existsSync : path.existsSync
+ , geddyApp = existsSync(configPath);
if(geddyApp) {
// Start the server
View
@@ -17,9 +17,11 @@
*/
var fs = require('fs')
+ , path = require('path')
+ , existsSync = typeof fs.existsSync == 'function' ?
+ fs.existsSync : path.existsSync
, url = require('url')
, querystring = require('../deps/qs')
- , path = require('path')
, cwd = process.cwd()
, errors = require('./response/errors')
, response = require('./response')
@@ -100,7 +102,7 @@ var App = function () {
, adapterPath
, appAdaptersPath = path.join(cwd, modelDir, '/adapters/');
// May be running entirely model-less
- if (!path.existsSync(path.join(cwd, modelDir))) {
+ if (!existsSync(path.join(cwd, modelDir))) {
next();
}
else {
@@ -117,10 +119,10 @@ var App = function () {
// - But I couldn't think of a reliable way that would work
// If the app has an adapter that matches the model adapter, use it.
- if (path.existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.js')) ||
- path.existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.coffee'))) {
+ if (existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.js')) ||
+ existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.coffee'))) {
- if(path.existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.coffee'))) {
+ if(existsSync(path.join(appAdaptersPath, adapterName.toLowerCase() + '.coffee'))) {
try {
usingCoffee = usingCoffee || require('coffee-script');
} catch(err) {
@@ -131,7 +133,7 @@ var App = function () {
geddy.model.adapter[item.ctorName] = require(adapterPath)[adapterName];
}
// if the model has been defined by geddy, use it.
- else if (path.existsSync(path.join(__dirname, "./model/adapters/", adapterName.toLowerCase() + '.js'))) {
+ else if (existsSync(path.join(__dirname, "./model/adapters/", adapterName.toLowerCase() + '.js'))) {
var config = {model: item.ctorName};
adapterPath = path.join(__dirname, "./model/adapters/", adapterName.toLowerCase());
geddy.model.adapter[item.ctorName] = require(adapterPath)[adapterName](config);
@@ -142,7 +144,7 @@ var App = function () {
}
// if the model doesn't define an adapter, use the default
else if (geddy.config.adapters && geddy.config.adapters.default &&
- path.existsSync(path.join(__dirname, "./model/adapters/", geddy.config.adapters.default+".js"))) {
+ existsSync(path.join(__dirname, "./model/adapters/", geddy.config.adapters.default+".js"))) {
geddy.model.adapter[item.ctorName] = require(path.join(__dirname, "./model/adapters/", geddy.config.adapters.default));
}
// the adapter will be undefined if the model doesn't define it,
@@ -179,7 +181,7 @@ var App = function () {
// ==================
, _loadRouter = function (next) {
routerCsFile = path.join(cwd, '/config/router.coffee');
- if(path.existsSync(routerCsFile)) {
+ if(existsSync(routerCsFile)) {
try {
require('coffee-script');
} catch(err) {
@@ -224,7 +226,7 @@ var App = function () {
, _registerTemplatePaths = function (next) {
var viewsPath = path.normalize('app/views');
// May be running entirely viewless
- if (!path.existsSync(viewsPath)) {
+ if (!existsSync(viewsPath)) {
this.templateRegistry = {};
next();
}
@@ -542,7 +544,7 @@ var App = function () {
// Decode path (e.g. %20)
staticPath = decodeURIComponent(staticPath);
- if (path.existsSync(staticPath)) {
+ if (existsSync(staticPath)) {
staticResp = new response.Response(resp);
staticResp.sendFile(staticPath);
}
View
@@ -2,6 +2,8 @@ var Master
, cluster
, fs = require('fs')
, path = require('path')
+ , existsSync = typeof fs.existsSync == 'function' ?
+ fs.existsSync : path.existsSync
, errors = require('../response/errors')
, watchFiles = require('../watch_files')
, Log = require('../../deps/log')
@@ -121,7 +123,7 @@ Master.prototype = new (function () {
types.forEach(function (type) {
var currentLog = path.join(dir, type + '.log')
, archivedLog = path.join(dir, type + '.' + now + '.log');
- if (path.existsSync(currentLog)) {
+ if (existsSync(currentLog)) {
try {
fs.renameSync(currentLog, archivedLog);
}
View
@@ -2,6 +2,8 @@ var i18n = require('../i18n')
, exec = require('child_process').exec
, path = require('path')
, fs = require('fs')
+ , existsSync = typeof fs.existsSync == 'function' ?
+ fs.existsSync : path.existsSync
, fileUtils = require('../utils/file');
module.exports = new (function () {
@@ -17,7 +19,7 @@ module.exports = new (function () {
, loadLocaleData = function () {
localePaths.forEach(function (directory) {
directory = path.normalize(directory);
- if (path.existsSync(directory)) {
+ if (existsSync(directory)) {
var files = fileUtils.readdirR(directory);
for (var i = 0; i < files.length; i++) {
file = files[i];

0 comments on commit de86f04

Please sign in to comment.