Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Commit 32a8b58

Browse files
committed
2 parents e184626 + 08d5114 commit 32a8b58

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

ClosureCompiler.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
(function(global) {
2323

24-
if ((typeof window != 'undefined' && !!window.window) || typeof require != 'function') {
24+
if (typeof require != 'function' || !module || !module.exports || !process) {
2525
throw(new Error("ClosureCompiler.js can only be used within node.js"));
2626
}
2727

@@ -175,14 +175,18 @@
175175
files = [files];
176176
}
177177
for (i=0; i<files.length; i++) {
178-
if (typeof files[i] != 'string' || files[i].indexOf('"') >= 0) {
178+
if (typeof files[i] != 'string') {
179179
throw(new Error("Illegal source file: "+files[i]));
180180
}
181-
stat = fs.statSync(files[i]);
182-
if (!stat.isFile()) {
183-
throw(new Error("Source file not found: "+files[i]));
181+
if (files[i].indexOf('"') >= 0) {
182+
args.push('--js=' + files[i]);
183+
} else {
184+
stat = fs.statSync(files[i]);
185+
if (!stat.isFile()) {
186+
throw (new Error("Source file not found: " + files[i]));
187+
}
188+
args.push('--js', files[i]);
184189
}
185-
args.push('--js', files[i]);
186190
}
187191

188192
// Externs files
@@ -265,6 +269,9 @@
265269
}
266270
callback(err, stdout, stderr);
267271
});
272+
process.on('error', function (err) {
273+
callback(err, stdout, stderr);
274+
});
268275
}
269276

270277
// Run it

0 commit comments

Comments
 (0)