From d958e83f1d73f546280156d3f638dab41411bd02 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Mon, 25 Apr 2016 17:20:46 -0400 Subject: [PATCH] build: add support for nodejs 0.10 For Ubuntu 14.04 Node.js compatibility: http://packages.ubuntu.com/trusty/nodejs --- .travis.yml | 1 + lib/scaffold/add.js | 7 ++++--- lib/scaffold/find-config.js | 3 ++- lib/scaffold/remove.js | 9 +++++---- lib/utils.js | 5 +++++ package.json | 1 + 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e1fcec0..c9912b43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ addons: - gcc-4.8 - libzmq3-dev node_js: + - "v0.10.25" - "v0.12.7" - "v4" script: diff --git a/lib/scaffold/add.js b/lib/scaffold/add.js index 5d0e6eea..76f24bdb 100644 --- a/lib/scaffold/add.js +++ b/lib/scaffold/add.js @@ -5,6 +5,7 @@ var fs = require('fs'); var path = require('path'); var spawn = require('child_process').spawn; var bitcore = require('bitcore-lib'); +var utils = require('../utils'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -14,7 +15,7 @@ var _ = bitcore.deps._; * @param {Function} done */ function addConfig(configFilePath, service, done) { - $.checkState(path.isAbsolute(configFilePath), 'An absolute path is expected'); + $.checkState(utils.isAbsolutePath(configFilePath), 'An absolute path is expected'); fs.readFile(configFilePath, function(err, data) { if (err) { return done(err); @@ -39,7 +40,7 @@ function addConfig(configFilePath, service, done) { * @param {Function} done */ function addService(configDir, service, done) { - $.checkState(path.isAbsolute(configDir), 'An absolute path is expected'); + $.checkState(utils.isAbsolutePath(configDir), 'An absolute path is expected'); var npm = spawn('npm', ['install', service, '--save'], {cwd: configDir}); npm.stdout.on('data', function(data) { @@ -69,7 +70,7 @@ function add(options, done) { $.checkArgument(_.isObject(options)); $.checkArgument(_.isFunction(done)); $.checkArgument( - _.isString(options.path) && path.isAbsolute(options.path), + _.isString(options.path) && utils.isAbsolutePath(options.path), 'An absolute path is expected' ); $.checkArgument(Array.isArray(options.services)); diff --git a/lib/scaffold/find-config.js b/lib/scaffold/find-config.js index f1c70b53..a4306e8b 100644 --- a/lib/scaffold/find-config.js +++ b/lib/scaffold/find-config.js @@ -5,6 +5,7 @@ var $ = bitcore.util.preconditions; var _ = bitcore.deps._; var path = require('path'); var fs = require('fs'); +var utils = require('../utils'); /** * Will return the path and bitcore-node configuration @@ -12,7 +13,7 @@ var fs = require('fs'); */ function findConfig(cwd) { $.checkArgument(_.isString(cwd), 'Argument should be a string'); - $.checkArgument(path.isAbsolute(cwd), 'Argument should be an absolute path'); + $.checkArgument(utils.isAbsolutePath(cwd), 'Argument should be an absolute path'); var directory = String(cwd); while (!fs.existsSync(path.resolve(directory, 'bitcore-node.json'))) { directory = path.resolve(directory, '../'); diff --git a/lib/scaffold/remove.js b/lib/scaffold/remove.js index d17dabf4..6d866d6f 100644 --- a/lib/scaffold/remove.js +++ b/lib/scaffold/remove.js @@ -8,6 +8,7 @@ var spawn = require('child_process').spawn; var bitcore = require('bitcore-lib'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; +var utils = require('../utils'); /** * Will remove a service from bitcore-node.json @@ -16,7 +17,7 @@ var _ = bitcore.deps._; * @param {Function} done */ function removeConfig(configFilePath, service, done) { - $.checkArgument(path.isAbsolute(configFilePath), 'An absolute path is expected'); + $.checkArgument(utils.isAbsolutePath(configFilePath), 'An absolute path is expected'); fs.readFile(configFilePath, function(err, data) { if (err) { return done(err); @@ -47,7 +48,7 @@ function removeConfig(configFilePath, service, done) { * @param {Function} done */ function uninstallService(configDir, service, done) { - $.checkArgument(path.isAbsolute(configDir), 'An absolute path is expected'); + $.checkArgument(utils.isAbsolutePath(configDir), 'An absolute path is expected'); $.checkArgument(_.isString(service), 'A string is expected for the service argument'); var child = spawn('npm', ['uninstall', service, '--save'], {cwd: configDir}); @@ -76,7 +77,7 @@ function uninstallService(configDir, service, done) { * @param {Function} done */ function removeService(configDir, service, done) { - $.checkArgument(path.isAbsolute(configDir), 'An absolute path is expected'); + $.checkArgument(utils.isAbsolutePath(configDir), 'An absolute path is expected'); $.checkArgument(_.isString(service), 'A string is expected for the service argument'); // check if the service is installed @@ -109,7 +110,7 @@ function remove(options, done) { $.checkArgument(_.isObject(options)); $.checkArgument(_.isFunction(done)); $.checkArgument( - _.isString(options.path) && path.isAbsolute(options.path), + _.isString(options.path) && utils.isAbsolutePath(options.path), 'An absolute path is expected' ); $.checkArgument(Array.isArray(options.services)); diff --git a/lib/utils.js b/lib/utils.js index 72cc58c1..cae2a5fe 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -21,4 +21,9 @@ utils.startAtZero = function startAtZero(obj, key) { } }; +utils.isAbsolutePath = require('path').isAbsolute; +if (!utils.isAbsolutePath) { + utils.isAbsolutePath = require('path-is-absolute'); +} + module.exports = utils; diff --git a/package.json b/package.json index fb4d1b2a..94fbf0bf 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "lru-cache": "^4.0.1", "mkdirp": "0.5.0", "npm": "^2.14.1", + "path-is-absolute": "^1.0.0", "semver": "^5.0.1", "socket.io": "^1.4.5", "socket.io-client": "^1.4.5",