Created
January 18, 2015 05:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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