From 9a14825a1a49d24be14b89e8e94c2e78ec6cea2c Mon Sep 17 00:00:00 2001 From: Brandon Frohs Date: Mon, 22 Apr 2013 12:44:31 -0400 Subject: [PATCH] Add `prefix` option. Same as `-p` and `--prefix` in CLI. --- tools/node.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/node.js b/tools/node.js index 1df61bcd..0bbdf6c6 100644 --- a/tools/node.js +++ b/tools/node.js @@ -59,6 +59,7 @@ exports.minify = function(files, options) { warnings : false, mangle : {}, output : null, + prefix : null, compress : {} }); if (typeof files == "string") @@ -70,6 +71,11 @@ exports.minify = function(files, options) { var code = options.fromString ? file : fs.readFileSync(file, "utf8"); + + if (options.prefix !== null) { + file = file.replace(/^\/+/, "").split(/\/+/).slice(options.prefix).join("/"); + } + toplevel = UglifyJS.parse(code, { filename: options.fromString ? "?" : file, toplevel: toplevel