Skip to content

Instantly share code, notes, and snippets.

@ChetHarrison
Created January 18, 2015 05:44
Show Gist options
  • Save ChetHarrison/1a0987396e3387a70b99 to your computer and use it in GitHub Desktop.
Save ChetHarrison/1a0987396e3387a70b99 to your computer and use it in GitHub Desktop.
Node tool to grab contents of url and return it in a string
'use strict';
var fs = require('fs'),
path = require('path'),
jsToAst = require('./src/parsers/js-to-ast.js'),
https = require('https'),
rawGitScrUrl = 'https://rawgit.com/marionettejs/backbone.marionette/master/src/',
get, srcFileList, options;
get = function(options) {
https.get(options, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log(chunk);
// console.log(jsToAst.parse(chunk)); // <-- here is our file in a string
});
}).on('error', function (e) {
console.log('Got error: ' + e.message);
});
};
options = {
hostname: 'api.github.com',
path: 'repos/marionettejs/backbone.marionette/contents/tree/master/src/',
headers: {
'User-Agent': 'ChetHarrison'
}
};
srcFileList = get(options);
console.log(srcFileList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment