mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 07:21:43 +00:00
Update bgloader.js
This commit is contained in:
parent
5910f93914
commit
d786940ebd
39
bgloader.js
39
bgloader.js
|
@ -1,3 +1,12 @@
|
|||
if (!Array.prototype.map) {
|
||||
Array.prototype.map = function(fn) {
|
||||
var rv = [];
|
||||
for (var i = 0; i < this.length; i++)
|
||||
rv.push(fn(this[i]));
|
||||
return rv;
|
||||
};
|
||||
}
|
||||
|
||||
function main() {
|
||||
var args = [];
|
||||
var argl = WScript.arguments.length;
|
||||
|
@ -6,7 +15,35 @@ function main() {
|
|||
}
|
||||
|
||||
var objShell = WScript.CreateObject("WScript.Shell");
|
||||
objShell.Run(args.join(' '), 0, true);
|
||||
objShell.Run(build(args), 0, true);
|
||||
}
|
||||
|
||||
function build(cmd) {
|
||||
if (typeof(cmd) === "string") {
|
||||
return cmd;
|
||||
} else if (typeof(cmd) === "object") {
|
||||
return cmd.map(function(s) {
|
||||
var regex = /[ "]/g;
|
||||
if (!regex.test(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return "\"" + addslashes(s) + "\"";
|
||||
}
|
||||
}).join(' ');
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function addslashes(s) {
|
||||
return s.toString().replace(/\\/g, '\\\\').
|
||||
replace(/\u0008/g, '\\b').
|
||||
replace(/\t/g, '\\t').
|
||||
replace(/\n/g, '\\n').
|
||||
replace(/\f/g, '\\f').
|
||||
replace(/\r/g, '\\r').
|
||||
replace(/'/g, '\\\'').
|
||||
replace(/"/g, '\\"');
|
||||
};
|
||||
|
||||
main();
|
Loading…
Reference in New Issue
Block a user