Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

have compress not exit prematurely when a syntax error exists in inpu…

…t - output a scary error message and nd return a non-zero exit code, but process all files closes #1257
  • Loading branch information...
commit 20cd1ac64c7861ff9e962053a0540782e53c1aaa 1 parent 389c549
@lloyd lloyd authored
Showing with 17 additions and 13 deletions.
  1. +17 −13 scripts/compress-worker.js
View
30 scripts/compress-worker.js
@@ -21,20 +21,24 @@ function compressResource(staticPath, name, files, cb) {
}
function compress() {
- var final_code;
- if (/\.js$/.test(name)) {
- // compress javascript
- var ast = jsp.parse(orig_code); // parse code and get the initial AST
- ast = pro.ast_mangle(ast); // get a new AST with mangled names
- ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
- final_code = pro.split_lines(pro.gen_code(ast), 32 * 1024); // compressed code here
- } else if (/\.css$/.test(name)) {
- // compress css
- final_code = uglifycss.processString(orig_code);
- } else {
- return cb("can't determine content type: " + name);
+ try {
+ var final_code;
+ if (/\.js$/.test(name)) {
+ // compress javascript
+ var ast = jsp.parse(orig_code); // parse code and get the initial AST
+ ast = pro.ast_mangle(ast); // get a new AST with mangled names
+ ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
+ final_code = pro.split_lines(pro.gen_code(ast), 32 * 1024); // compressed code here
+ } else if (/\.css$/.test(name)) {
+ // compress css
+ final_code = uglifycss.processString(orig_code);
+ } else {
+ return cb("can't determine content type: " + name);
+ }
+ writeFile(final_code);
+ } catch(e) {
+ cb("error compressing: " + e.toString() + "\n");
}
- writeFile(final_code);
}
function readNext() {
Please sign in to comment.
Something went wrong with that request. Please try again.