mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 21:26:04 +00:00
Update shell.js
This commit is contained in:
parent
3e67209ae8
commit
9dda6f1e09
18
lib/shell.js
18
lib/shell.js
|
@ -16,6 +16,7 @@ var ShellObject = function() {
|
||||||
|
|
||||||
this.stdout = null;
|
this.stdout = null;
|
||||||
this.stderr = null;
|
this.stderr = null;
|
||||||
|
this.target = null;
|
||||||
|
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
try {
|
try {
|
||||||
|
@ -28,6 +29,9 @@ var ShellObject = function() {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setTarget = function(target) {
|
||||||
|
this.target = target;
|
||||||
|
};
|
||||||
|
|
||||||
this.setCharset = function(charset) {
|
this.setCharset = function(charset) {
|
||||||
this.charset = charset;
|
this.charset = charset;
|
||||||
|
@ -49,10 +53,14 @@ var ShellObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.build = function(cmd) {
|
this.build = function(cmd) {
|
||||||
|
var wrap = function(s) {
|
||||||
|
return this.target != null ? [this.target, s].join(' ') : s;
|
||||||
|
};
|
||||||
|
|
||||||
if (typeof(cmd) === "string") {
|
if (typeof(cmd) === "string") {
|
||||||
return cmd;
|
return wrap(cmd);
|
||||||
} else if (typeof(cmd) === "object") {
|
} else if (typeof(cmd) === "object") {
|
||||||
return cmd.map(function(s) {
|
return wrap(cmd.map(function(s) {
|
||||||
if (s == '') {
|
if (s == '') {
|
||||||
return "''";
|
return "''";
|
||||||
} else if (!/[ "=]/g.test(s)) {
|
} else if (!/[ "=]/g.test(s)) {
|
||||||
|
@ -60,9 +68,9 @@ var ShellObject = function() {
|
||||||
} else {
|
} else {
|
||||||
return "\"" + addslashes(s) + "\"";
|
return "\"" + addslashes(s) + "\"";
|
||||||
}
|
}
|
||||||
}).join(' ');
|
}).join(' '));
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return wrap('');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -212,7 +220,7 @@ exports.getPathOfMyDocuments = function() {
|
||||||
|
|
||||||
exports.CdoCharset = PipeIPC.CdoCharset;
|
exports.CdoCharset = PipeIPC.CdoCharset;
|
||||||
|
|
||||||
exports.VERSIONINFO = "Shell interface (shell.js) version 0.3.7";
|
exports.VERSIONINFO = "Shell interface (shell.js) version 0.3.8";
|
||||||
exports.AUTHOR = "abuse@catswords.net";
|
exports.AUTHOR = "abuse@catswords.net";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user