From 38bf218e7ed1cc2f02e4cf5c8182f7b0164f7493 Mon Sep 17 00:00:00 2001 From: TGJ Gilmore Date: Tue, 14 Jun 2016 08:23:57 +0100 Subject: [PATCH] Update uglifyjs Revised the input parameters to allow for the JS source to be folders of JS files as well as just JS files. --- bin/uglifyjs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/uglifyjs b/bin/uglifyjs index 45c92b50..83d8c0d5 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -254,7 +254,22 @@ if (ARGS.comments != null) { } } -var files = ARGS._.slice(); +var files = (function expand_folder_of_JS_files( arrFiles) { + var arrJS_files = []; + arrFiles.forEach( function(filename) { + var fsStats = fs.statSync(filename); + if (fsStats.isFile() && filename.match(/.js$/i)) { arrJS_files.push(filename);} + else if (fsStats.isDirectory()) { + var strFolder = fs.realpathSync(filename)+ "/"; + var arrDir = fs.readdirSync(strFolder,'utf8'); + arrDir.forEach( function(dirFile) { + var arrFile = expand_folder_of_JS_files( [strFolder+ dirFile]); + if (arrFile && arrFile.length) { arrJS_files.push(arrFile[0]);} + }); + } + }); + return arrJS_files; +})(ARGS._.slice()); if (ARGS.self) { if (files.length > 0) {