Update compress
This commit is contained in:
parent
1705ab3327
commit
3835a69770
|
@ -6,7 +6,7 @@
|
||||||
//
|
//
|
||||||
// bin/compress codemirror runmode javascript xml
|
// bin/compress codemirror runmode javascript xml
|
||||||
//
|
//
|
||||||
// Will take lib/codemirror.js, lib/util/runmode.js,
|
// Will take lib/codemirror.js, addon/runmode/runmode.js,
|
||||||
// mode/javascript/javascript.js, and mode/xml/xml.js, run them though
|
// mode/javascript/javascript.js, and mode/xml/xml.js, run them though
|
||||||
// the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit
|
// the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit
|
||||||
// out the result.
|
// out the result.
|
||||||
|
@ -29,14 +29,15 @@ function help(ok) {
|
||||||
process.exit(ok ? 0 : 1);
|
process.exit(ok ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var local = null, args = null, files = [], blob = "";
|
var local = null, args = [], extraArgs = null, files = [], blob = "";
|
||||||
|
|
||||||
for (var i = 2; i < process.argv.length; ++i) {
|
for (var i = 2; i < process.argv.length; ++i) {
|
||||||
var arg = process.argv[i];
|
var arg = process.argv[i];
|
||||||
if (arg == "--local" && i + 1 < process.argv.length) {
|
if (arg == "--local" && i + 1 < process.argv.length) {
|
||||||
var parts = process.argv[++i].split(/\s+/);
|
var parts = process.argv[++i].split(/\s+/);
|
||||||
local = parts[0];
|
local = parts[0];
|
||||||
args = parts.slice(1);
|
extraArgs = parts.slice(1);
|
||||||
|
if (!extraArgs.length) extraArgs = ["-c", "-m"];
|
||||||
} else if (arg == "--help") {
|
} else if (arg == "--help") {
|
||||||
help(true);
|
help(true);
|
||||||
} else if (arg[0] != "-") {
|
} else if (arg[0] != "-") {
|
||||||
|
@ -61,8 +62,11 @@ function walk(dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
walk("lib/");
|
walk("lib/");
|
||||||
|
walk("addon/");
|
||||||
walk("mode/");
|
walk("mode/");
|
||||||
|
|
||||||
|
if (!local && !blob) help(false);
|
||||||
|
|
||||||
if (files.length) {
|
if (files.length) {
|
||||||
console.log("Some speficied files were not found: " +
|
console.log("Some speficied files were not found: " +
|
||||||
files.map(function(a){return a.name;}).join(", "));
|
files.map(function(a){return a.name;}).join(", "));
|
||||||
|
@ -70,7 +74,7 @@ if (files.length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
require("child_process").spawn(local, args, {stdio: ["ignore", process.stdout, process.stderr]});
|
require("child_process").spawn(local, args.concat(extraArgs), {stdio: ["ignore", process.stdout, process.stderr]});
|
||||||
} else {
|
} else {
|
||||||
var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8");
|
var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8");
|
||||||
var req = require("http").request({
|
var req = require("http").request({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user