mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-12 00:45:14 +00:00
Update shell.js
This commit is contained in:
parent
3e67209ae8
commit
9dda6f1e09
22
lib/shell.js
22
lib/shell.js
|
@ -16,18 +16,22 @@ var ShellObject = function() {
|
|||
|
||||
this.stdout = null;
|
||||
this.stderr = null;
|
||||
this.target = null;
|
||||
|
||||
this.create = function() {
|
||||
try {
|
||||
this.interface = CreateObject("WScript.Shell");
|
||||
this.currentDirectory = this.interface.CurrentDirectory;
|
||||
this.workingDirectory = this.currentDirectory;
|
||||
this.workingDirectory = this.currentDirectory;
|
||||
} catch (e) {
|
||||
console.error("ShellObject.create() ->", e.message);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
this.setTarget = function(target) {
|
||||
this.target = target;
|
||||
};
|
||||
|
||||
this.setCharset = function(charset) {
|
||||
this.charset = charset;
|
||||
|
@ -49,10 +53,14 @@ var ShellObject = function() {
|
|||
};
|
||||
|
||||
this.build = function(cmd) {
|
||||
var wrap = function(s) {
|
||||
return this.target != null ? [this.target, s].join(' ') : s;
|
||||
};
|
||||
|
||||
if (typeof(cmd) === "string") {
|
||||
return cmd;
|
||||
return wrap(cmd);
|
||||
} else if (typeof(cmd) === "object") {
|
||||
return cmd.map(function(s) {
|
||||
return wrap(cmd.map(function(s) {
|
||||
if (s == '') {
|
||||
return "''";
|
||||
} else if (!/[ "=]/g.test(s)) {
|
||||
|
@ -60,9 +68,9 @@ var ShellObject = function() {
|
|||
} else {
|
||||
return "\"" + addslashes(s) + "\"";
|
||||
}
|
||||
}).join(' ');
|
||||
}).join(' '));
|
||||
} else {
|
||||
return "";
|
||||
return wrap('');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -212,7 +220,7 @@ exports.getPathOfMyDocuments = function() {
|
|||
|
||||
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.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user