mirror of https://github.com/embarklabs/embark.git
move request to utils module
This commit is contained in:
parent
a25d225a8b
commit
08ba95576d
|
@ -1,6 +1,6 @@
|
||||||
var Web3 = require('web3');
|
var Web3 = require('web3');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var request = require('request');
|
var utils = require('./utils.js');
|
||||||
|
|
||||||
var ServicesMonitor = function(options) {
|
var ServicesMonitor = function(options) {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
@ -57,11 +57,11 @@ ServicesMonitor.prototype.check = function() {
|
||||||
function checkIPFS(result, callback) {
|
function checkIPFS(result, callback) {
|
||||||
self.logger.trace('checkIPFS');
|
self.logger.trace('checkIPFS');
|
||||||
|
|
||||||
request('http://localhost:5001', function(error, response, body) {
|
utils.checkIsAvailable('http://localhost:5001', function(available) {
|
||||||
if (error) {
|
if (available) {
|
||||||
result.push('IPFS'.red);
|
|
||||||
} else {
|
|
||||||
result.push('IPFS'.green);
|
result.push('IPFS'.green);
|
||||||
|
} else {
|
||||||
|
result.push('IPFS'.red);
|
||||||
}
|
}
|
||||||
callback(null, result);
|
callback(null, result);
|
||||||
});
|
});
|
||||||
|
|
10
lib/utils.js
10
lib/utils.js
|
@ -1,6 +1,7 @@
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var grunt = require('grunt');
|
var grunt = require('grunt');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
|
var request = require('request');
|
||||||
|
|
||||||
function joinPath() {
|
function joinPath() {
|
||||||
return path.join.apply(path.join, arguments);
|
return path.join.apply(path.join, arguments);
|
||||||
|
@ -18,10 +19,17 @@ function recursiveMerge(target, source) {
|
||||||
return merge.recursive(target, source);
|
return merge.recursive(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkIsAvailable(url, callback) {
|
||||||
|
request(url, function(error, response, body) {
|
||||||
|
callback(!error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
joinPath: joinPath,
|
joinPath: joinPath,
|
||||||
filesMatchingPattern: filesMatchingPattern,
|
filesMatchingPattern: filesMatchingPattern,
|
||||||
fileMatchesPattern: fileMatchesPattern,
|
fileMatchesPattern: fileMatchesPattern,
|
||||||
recursiveMerge: recursiveMerge
|
recursiveMerge: recursiveMerge,
|
||||||
|
checkIsAvailable: checkIsAvailable
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue