build: add support for nodejs 0.10

For Ubuntu 14.04 Node.js compatibility: http://packages.ubuntu.com/trusty/nodejs
This commit is contained in:
Braydon Fuller 2016-04-25 17:20:46 -04:00
parent 9e0e9a2c89
commit d958e83f1d
6 changed files with 18 additions and 8 deletions

View File

@ -11,6 +11,7 @@ addons:
- gcc-4.8 - gcc-4.8
- libzmq3-dev - libzmq3-dev
node_js: node_js:
- "v0.10.25"
- "v0.12.7" - "v0.12.7"
- "v4" - "v4"
script: script:

View File

@ -5,6 +5,7 @@ var fs = require('fs');
var path = require('path'); var path = require('path');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var bitcore = require('bitcore-lib'); var bitcore = require('bitcore-lib');
var utils = require('../utils');
var $ = bitcore.util.preconditions; var $ = bitcore.util.preconditions;
var _ = bitcore.deps._; var _ = bitcore.deps._;
@ -14,7 +15,7 @@ var _ = bitcore.deps._;
* @param {Function} done * @param {Function} done
*/ */
function addConfig(configFilePath, service, 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) { fs.readFile(configFilePath, function(err, data) {
if (err) { if (err) {
return done(err); return done(err);
@ -39,7 +40,7 @@ function addConfig(configFilePath, service, done) {
* @param {Function} done * @param {Function} done
*/ */
function addService(configDir, service, 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}); var npm = spawn('npm', ['install', service, '--save'], {cwd: configDir});
npm.stdout.on('data', function(data) { npm.stdout.on('data', function(data) {
@ -69,7 +70,7 @@ function add(options, done) {
$.checkArgument(_.isObject(options)); $.checkArgument(_.isObject(options));
$.checkArgument(_.isFunction(done)); $.checkArgument(_.isFunction(done));
$.checkArgument( $.checkArgument(
_.isString(options.path) && path.isAbsolute(options.path), _.isString(options.path) && utils.isAbsolutePath(options.path),
'An absolute path is expected' 'An absolute path is expected'
); );
$.checkArgument(Array.isArray(options.services)); $.checkArgument(Array.isArray(options.services));

View File

@ -5,6 +5,7 @@ var $ = bitcore.util.preconditions;
var _ = bitcore.deps._; var _ = bitcore.deps._;
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
var utils = require('../utils');
/** /**
* Will return the path and bitcore-node configuration * Will return the path and bitcore-node configuration
@ -12,7 +13,7 @@ var fs = require('fs');
*/ */
function findConfig(cwd) { function findConfig(cwd) {
$.checkArgument(_.isString(cwd), 'Argument should be a string'); $.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); var directory = String(cwd);
while (!fs.existsSync(path.resolve(directory, 'bitcore-node.json'))) { while (!fs.existsSync(path.resolve(directory, 'bitcore-node.json'))) {
directory = path.resolve(directory, '../'); directory = path.resolve(directory, '../');

View File

@ -8,6 +8,7 @@ var spawn = require('child_process').spawn;
var bitcore = require('bitcore-lib'); var bitcore = require('bitcore-lib');
var $ = bitcore.util.preconditions; var $ = bitcore.util.preconditions;
var _ = bitcore.deps._; var _ = bitcore.deps._;
var utils = require('../utils');
/** /**
* Will remove a service from bitcore-node.json * Will remove a service from bitcore-node.json
@ -16,7 +17,7 @@ var _ = bitcore.deps._;
* @param {Function} done * @param {Function} done
*/ */
function removeConfig(configFilePath, service, 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) { fs.readFile(configFilePath, function(err, data) {
if (err) { if (err) {
return done(err); return done(err);
@ -47,7 +48,7 @@ function removeConfig(configFilePath, service, done) {
* @param {Function} done * @param {Function} done
*/ */
function uninstallService(configDir, service, 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'); $.checkArgument(_.isString(service), 'A string is expected for the service argument');
var child = spawn('npm', ['uninstall', service, '--save'], {cwd: configDir}); var child = spawn('npm', ['uninstall', service, '--save'], {cwd: configDir});
@ -76,7 +77,7 @@ function uninstallService(configDir, service, done) {
* @param {Function} done * @param {Function} done
*/ */
function removeService(configDir, service, 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'); $.checkArgument(_.isString(service), 'A string is expected for the service argument');
// check if the service is installed // check if the service is installed
@ -109,7 +110,7 @@ function remove(options, done) {
$.checkArgument(_.isObject(options)); $.checkArgument(_.isObject(options));
$.checkArgument(_.isFunction(done)); $.checkArgument(_.isFunction(done));
$.checkArgument( $.checkArgument(
_.isString(options.path) && path.isAbsolute(options.path), _.isString(options.path) && utils.isAbsolutePath(options.path),
'An absolute path is expected' 'An absolute path is expected'
); );
$.checkArgument(Array.isArray(options.services)); $.checkArgument(Array.isArray(options.services));

View File

@ -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; module.exports = utils;

View File

@ -53,6 +53,7 @@
"lru-cache": "^4.0.1", "lru-cache": "^4.0.1",
"mkdirp": "0.5.0", "mkdirp": "0.5.0",
"npm": "^2.14.1", "npm": "^2.14.1",
"path-is-absolute": "^1.0.0",
"semver": "^5.0.1", "semver": "^5.0.1",
"socket.io": "^1.4.5", "socket.io": "^1.4.5",
"socket.io-client": "^1.4.5", "socket.io-client": "^1.4.5",