Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

change path.exists calls to use fs.exists for node 0.8.x

  • Loading branch information...
commit 0a3993de612ef8d5c22b97bf084a9459b86b354a 1 parent f563bc1
@caolan caolan authored
View
4 lib/cache.js
@@ -1,7 +1,7 @@
var tar = require('./tar'),
utils = require('./utils'),
async = require('async'),
- path = require('path');
+ pathExists = require('fs').exists || require('path').exists;
exports.CACHE_DIR = process.env.HOME + '/.kanso/cache';
@@ -36,7 +36,7 @@ exports.get = function (name, version, callback) {
var tarfile = dir + '/' + filename
var cachedir = dir + '/package';
- path.exists(cachedir, function (exists) {
+ pathExists(cachedir, function (exists) {
if (exists) {
return callback(null, tarfile, cachedir);
}
View
5 lib/commands/install.js
@@ -16,7 +16,8 @@ var semver = require('semver'),
clean = require('./clean'),
async = require('async'),
path = require('path'),
- fs = require('fs');
+ fs = require('fs'),
+ pathExists = fs.exists || path.exists;
/**
@@ -347,7 +348,7 @@ exports.cpDir = function (name, v, from_cache, cdir, opt, callback) {
});
});
}
- path.exists(p, function (exists) {
+ pathExists(p, function (exists) {
if (exists) {
logger.info('removing', name);
utils.rm('-rf', p, function (err) {
View
4 lib/commands/push.js
@@ -6,6 +6,8 @@ var utils = require('../utils'),
argParse = require('../args').parse,
exec = require('child_process').exec,
path = require('path'),
+ fs = require('fs'),
+ pathExists = fs.exists || path.exists,
url = require('url'),
urlParse = url.parse,
urlFormat = url.format;
@@ -42,7 +44,7 @@ exports.run = function (settings, args) {
});
var url;
var dir = a.positional[0] || '.';
- path.exists(dir, function (exists) {
+ pathExists(dir, function (exists) {
if (!exists) {
dir = process.cwd();
url = a.positional[0];
View
4 lib/kansorc.js
@@ -8,7 +8,7 @@
var utils = require('./utils'),
async = require('async'),
_ = require('underscore')._,
- path = require('path');
+ pathExists = require('fs').exists || require('path').exists;
/**
@@ -96,7 +96,7 @@ exports.merge = function (a, b) {
*/
exports.loadFile = function (p, callback) {
- path.exists(p, function (exists) {
+ pathExists(p, function (exists) {
if (exists) {
try {
var mod = require(utils.abspath(p));
View
3  lib/packages.js
@@ -11,6 +11,7 @@ var settings = require('./settings'),
logger = require('./logger'),
utils = require('./utils'),
path = require('path'),
+ pathExists = require('fs').exists || require('path').exists,
semver = require('semver'),
events = require('events'),
_ = require('underscore')._;
@@ -441,7 +442,7 @@ exports.resolveCandidates = function (name, source, paths) {
exports.availableVersions = function (candidates, callback) {
var versions = {};
async.forEach(candidates, function (c, cb) {
- path.exists(path.join(c, 'kanso.json'), function (exists) {
+ pathExists(path.join(c, 'kanso.json'), function (exists) {
if (exists) {
settings.load(c, function (err, doc) {
if (err) {
View
6 lib/tar.js
@@ -4,7 +4,9 @@ var child_process = require('child_process'),
settings = require('./settings'),
logger = require('./logger'),
utils = require('./utils'),
- path = require('path');
+ path = require('path'),
+ fs = require('fs'),
+ pathExists = fs.exists || path.exists;
/**
@@ -84,7 +86,7 @@ exports.create = function (outfile, dir, callback) {
path.basename(outfile) + '-' + new Date().getTime();
var ignorefile = path.join(dir, '.kansoignore');
- path.exists(ignorefile, function (ignores) {
+ pathExists(ignorefile, function (ignores) {
var outpath = utils.abspath(tmpfile, process.cwd());
exports.excludeList(dir, cfg, function (err, excludes) {
View
2  package.json
@@ -23,7 +23,7 @@
"url": "http://github.com/caolan/kanso.git"
},
- "engines": {"node": "~0.4.0 || ~0.6.6"},
+ "engines": {"node": "~0.4.0 || ~0.6.6 || ~0.8.0"},
"bugs": {"url": "http://github.com/caolan/kanso/issues"},
"bin": {
"kanso": "./bin/kanso",
View
12 test/test-lib-kansorc.js
@@ -1,7 +1,7 @@
var utils = require('../lib/utils'),
kansorc = require('../lib/kansorc'),
nodeunit = require('nodeunit'),
- path = require('path'),
+ fs = require('fs'),
logger = require('../lib/logger'),
_ = require('underscore')._;
@@ -14,7 +14,7 @@ exports.kansorc = nodeunit.testCase({
var _PATHS = kansorc.PATHS;
this._DEFAULTS = kansorc.DEFAULTS;
this._loadFile = kansorc.loadFile;
- this._exists = path.exists;
+ this._exists = fs.exists;
cb();
},
@@ -22,7 +22,7 @@ exports.kansorc = nodeunit.testCase({
kansorc.PATHS = this._PATHS;
kansorc.DEFAULTS = this._DEFAULTS;
kansorc.loadFile = this._loadFile;
- path.exists = this._exists;
+ fs.exists = this._exists;
cb();
},
@@ -32,7 +32,7 @@ exports.kansorc = nodeunit.testCase({
var rcdata = {
test: 'test'
};
- path.exists = function (p, cb) {
+ fs.exists = function (p, cb) {
cb(true);
};
var paths = [];
@@ -52,7 +52,7 @@ exports.kansorc = nodeunit.testCase({
var paths = [];
kansorc.PATHS = ['rcone', 'rctwo', 'rcthree'];
kansorc.DEFAULTS = {defaults: true};
- path.exists = function (p, cb) {
+ fs.exists = function (p, cb) {
cb(true);
};
kansorc.loadFile = function (p, cb) {
@@ -82,7 +82,7 @@ exports.kansorc = nodeunit.testCase({
bar: 0,
baz: 0
};
- path.exists = function (p, cb) {
+ fs.exists = function (p, cb) {
cb(true);
};
var rcdata = {
View
3  test/test-lib-utils.js
@@ -1,5 +1,4 @@
var utils = require('../lib/utils'),
- path = require('path'),
fs = require('fs'),
child_process = require('child_process'),
logger = require('../lib/logger');
@@ -146,7 +145,7 @@ exports['ensureDir - new dirs'] = function (test) {
rm.on('exit', function (code) {
utils.ensureDir(p, function (err) {
if (err) throw err;
- path.exists(p, function (exists) {
+ fs.exists(p, function (exists) {
test.ok(exists);
test.done();
});
Please sign in to comment.
Something went wrong with that request. Please try again.