From efb0e94d99b78533475859bad3c1c84238fa17d5 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Sat, 28 Oct 2017 22:57:52 -0700 Subject: [PATCH] fix: closure compiler requires HTTPS now (#2007) Also barfing out the response from the server when JSON parsing errors happen --- bundler/minify.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bundler/minify.js b/bundler/minify.js index 51b2b775..3b1d3cae 100644 --- a/bundler/minify.js +++ b/bundler/minify.js @@ -1,6 +1,6 @@ "use strict" -var http = require("http") +var http = require("https") var querystring = require("querystring") var fs = require("fs") @@ -22,7 +22,6 @@ module.exports = function(input, output, options, done) { var response = "" var req = http.request({ method: "POST", - protocol: "http:", hostname: "closure-compiler.appspot.com", path: "/compile", headers: { @@ -33,8 +32,16 @@ module.exports = function(input, output, options, done) { res.on("data", function(chunk) { response += chunk.toString() }) + res.on("end", function() { - var results = JSON.parse(response) + try { + var results = JSON.parse(response) + } catch(e) { + console.error(response); + + throw e; + } + if (results.errors) { for (var i = 0; i < results.errors.length; i++) console.log(results.errors[i]) }