prepublish.js
function getJSON(jsonUrl, done) {
    var parsedUrl = url.parse(jsonUrl);
    
    var options = {
        "host" : parsedUrl.hostname,
        "hostname": parsedUrl.hostname,
        "port" : parsedUrl.port || 80,
        "path" : parsedUrl.pathname,
        "method" : "GET",
        // "agent" : false,
    };
    
    debug && console.error("prepublish:getJSON('" + jsonUrl + "', done)");
    debug && console.error("options=" + util.inspect(options));
    var req = http.get(options, function (res) {
        debug && console.error("STATUS: " + res.statusCode);
        debug && console.error("HEADERS: " + JSON.stringify(res.headers));
        res.setEncoding('utf8');
        var data = '';
        res.on('data', function (chunk) {
            debug && console.error('getJSON: chunk="' + chunk + '"');
            data += chunk;
        });
        res.on('end', function() {
            debug && console.error('getJSON: end of request.');
            done(JSON.parse(data));
        });
    });

    req.on('error', function(error) {
        console.error("ERROR: " + error.message);
    });
}
function getJSON(jsonUrl, done) {
    var parsedUrl = url.parse(jsonUrl);
    
    var options = {
        "host" : parsedUrl.hostname,
        "hostname": parsedUrl.hostname,
        "port" : parsedUrl.port || 80,
        "path" : parsedUrl.pathname,
        "method" : "GET",
        // "agent" : false,
    };
    
    debug && console.error("prepublish:getJSON('" + jsonUrl + "', done)");
    debug && console.error("options=" + util.inspect(options));
    var req = http.get(options, function (res) {
        debug && console.error("STATUS: " + res.statusCode);
        debug && console.error("HEADERS: " + JSON.stringify(res.headers));
        res.setEncoding('utf8');
        var data = '';
        res.on('data', function (chunk) {
            debug && console.error('getJSON: chunk="' + chunk + '"');
            data += chunk;
        });
        res.on('end', function() {
            debug && console.error('getJSON: end of request.');
            done(JSON.parse(data));
        });
    });

    req.on('error', function(error) {
        console.error("ERROR: " + error.message);
    });
}
function getJSON ( jsonUrl , done ) { var parsedUrl = url . parse ( jsonUrl ) ; var options = { "host" : parsedUrl . hostname , "hostname" : parsedUrl . hostname , "port" : parsedUrl . port || 80 , "path" : parsedUrl . pathname , "method" : "GET" , // "agent" : false, } ; debug && console . error ( "prepublish:getJSON('" + jsonUrl + "', done)" ) ; debug && console . error ( "options=" + util . inspect ( options ) ) ; var req = http . get ( options , function ( res ) { debug && console . error ( "STATUS: " + res . statusCode ) ; debug && console . error ( "HEADERS: " + JSON . stringify ( res . headers ) ) ; res . setEncoding ( 'utf8' ) ; var data = '' ; res . on ( 'data' , function ( chunk ) { debug && console . error ( 'getJSON: chunk="' + chunk + '"' ) ; data += chunk ; } ) ; res . on ( 'end' , function ( ) { debug && console . error ( 'getJSON: end of request.' ) ; done ( JSON . parse ( data ) ) ; } ) ; } ) ; req . on ( 'error' , function ( error ) { console . error ( "ERROR: " + error . message ) ; } ) ; }
Download JSON object from a remote URL.

@param path to request.
@param done callback.
Download JSON object from a remote URL .