Skip to content

Commit 2bc1665

Browse files
committed
path.exists is now called fs.exists
Fix for modern Nodes to stop complaining about calls to path.exists
1 parent 03311e4 commit 2bc1665

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

build/packed_helper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ function rewriteMappings(type, pluginList, callback) {
7373
var dir = "";
7474
var c9Prefix = "../plugins-client/ext.";
7575
var infraPrefix = "../plugins-client/ext.";
76+
var exists = fs.existsSync || path.existsSync;
7677

77-
if (!path.existsSync(path.normalize(__dirname + "/" + c9Prefix + name))) {
78+
if (!exists(path.normalize(__dirname + "/" + c9Prefix + name))) {
7879
//console.warn("Couldn't find " + path.normalize(__dirname + "/" + c9Prefix + name) + "; looking elsewhere...");
79-
if (!path.existsSync(path.normalize(__dirname + "/" + infraPrefix + name))) {
80+
if (!exists(path.normalize(__dirname + "/" + infraPrefix + name))) {
8081
//console.warn("Couldn't find " + path.normalize(__dirname + "/" + infraPrefix + name) + "; looking elsewhere...");
8182

8283
console.error("We have a problem. I have no idea where " + name + " is referenced.");

plugins-server/connect.session.file/session-ext.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ var assert = require("assert");
22
var path = require("path");
33
var fs = require("fs");
44
var Store = require("connect/lib/middleware/session/store");
5+
var exists = fs.existsSync || path.existsSync;
56

67
module.exports = function startup(options, imports, register) {
78

89
assert(options.sessionsPath, "option 'sessionsPath' is required");
910

10-
if (!path.existsSync(path.dirname(options.sessionsPath))) {
11+
if (!exists(path.dirname(options.sessionsPath))) {
1112
fs.mkdir(path.dirname(options.sessionsPath), 0755);
1213
}
13-
if (!path.existsSync(options.sessionsPath)) {
14+
if (!exists(options.sessionsPath)) {
1415
fs.mkdir(options.sessionsPath, 0755);
1516
}
1617

@@ -69,7 +70,8 @@ FileStore.prototype.__proto__ = Store.prototype;
6970

7071
FileStore.prototype.get = function(sid, fn){
7172
var self = this;
72-
path.exists(self.basePath + "/" + sid, function(exists) {
73+
var exists = fs.exists || path.exists;
74+
exists(self.basePath + "/" + sid, function(exists) {
7375
if (exists) {
7476
fs.readFile(self.basePath + "/" + sid, function(err, data) {
7577
if (err) {
@@ -117,7 +119,8 @@ FileStore.prototype.set = function(sid, sess, fn){
117119

118120
FileStore.prototype.destroy = function(sid, fn){
119121
var self = this;
120-
path.exists(self.basePath + "/" + sid, function(exists) {
122+
var exists = fs.exists || path.exists;
123+
exists(self.basePath + "/" + sid, function(exists) {
121124
if (exists) {
122125
fs.unlink(self.basePath + "/" + sid, function(err) {
123126
if (err) {

server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ process.title = title_parts.join(' ');
2929
var debug = false;
3030
var packed = false;
3131
var packedName = "";
32+
var exists = fs.existsSync || path.existsSync;
3233

3334
for (var p = 2; p < process.argv.length; p++) {
3435
if (process.argv[p] === "-d") {
3536
debug = true;
3637

3738
// apf debug doesn't exist, or it's older than three days--rebuild it
38-
if(!path.existsSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js") ||
39-
(path.existsSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js")) &&
39+
if(!exists("plugins-client/lib.apf/www/apf-packaged/apf_debug.js") ||
40+
(exists("plugins-client/lib.apf/www/apf-packaged/apf_debug.js")) &&
4041
((new Date() - fs.statSync("plugins-client/lib.apf/www/apf-packaged/apf_debug.js").mtime.valueOf()) / 86400000) >= 3) {
4142
console.log("Building apfdebug for first run...");
4243

@@ -68,7 +69,7 @@ for (var p = 2; p < process.argv.length; p++) {
6869

6970
configName = "packed";
7071

71-
if(!path.existsSync("plugins-client/lib.packed/www/" + packedName) && !path.existsSync("plugins-client/lib.packed/www/" + packedName + ".gz")) {
72+
if(!exists("plugins-client/lib.packed/www/" + packedName) && !exists("plugins-client/lib.packed/www/" + packedName + ".gz")) {
7273
console.log("Building packed file for first run...Please wait...");
7374
console.log(" |\\ _,,,---,,_\n" +
7475
" /,`.-'`' -. ;-;;,_\n" +

0 commit comments

Comments
 (0)