Skip to content

Commit

Permalink
automatically download prettify files
Browse files Browse the repository at this point in the history
  • Loading branch information
clmath committed Nov 24, 2014
1 parent 52f1683 commit d5a76ea
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
40 changes: 40 additions & 0 deletions installPrettify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var request = require("https").request;
var fs = require("fs");

function getOptions(file) {
return {
hostname: "google-code-prettify.googlecode.com",
path: "/svn/branches/release-4-Mar-2013/src/" + file,
method: "GET",
headers: {
"user-agent": "nodejs"
}
};
}

var files = ["prettify.js", "lang-css.js"];
var dest = __dirname + "/templates/amddcl/static/scripts/prettify/";

fs.mkdirSync(dest);

files.forEach(function (file) {
request(getOptions(file), function (res) {
var statusCode = res.statusCode;
if (statusCode === 404) {
console.log("File " + file + " not found.");
} else if (statusCode === 200) {
var data = "";
res.on("data", function (chunk) {
data += chunk.toString();
});

res.on("end", function () {
fs.writeFileSync(dest + file, data);
});
} else {
console.log(file + ": " + "HTTP GET Error " + statusCode);
}
}).on("error", function (e) {
console.log(e);
}).end();
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"taffydb": "https://github.com/hegemonic/taffydb/tarball/master",
"catharsis": "~0.7.1"
},
"scripts": {
"postinstall": "node installPrettify.js"
},
"devDependencies": {
"grunt": "~0.4.0"
},
Expand Down

0 comments on commit d5a76ea

Please sign in to comment.