mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 05:31:03 +00:00
Update app.js
This commit is contained in:
parent
7fe5182e54
commit
80947df3f8
43
app.js
43
app.js
|
@ -58,16 +58,47 @@ var console = {
|
||||||
},
|
},
|
||||||
_echoCallback: null,
|
_echoCallback: null,
|
||||||
_echo: function(args, type) {
|
_echo: function(args, type) {
|
||||||
// if not type is "log", then "{type}: {msg}"
|
var message = "";
|
||||||
msg = (typeof(type) !== "undefined" ? type + ": " : "") + this._join(args);
|
var params = {
|
||||||
if (typeof(WScript) !== "undefined") {
|
type: type,
|
||||||
WScript.echo(" * " + msg);
|
channel: 'default',
|
||||||
|
messsage: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
if (args.length > 0) {
|
||||||
|
if (typeof args[0] === "string") {
|
||||||
|
// if not type is "log", then "{type}: {message}"
|
||||||
|
if (typeof type !== "undefined") {
|
||||||
|
message += (type + ": " + this._join(args));
|
||||||
|
} else {
|
||||||
|
message += this._join(args);
|
||||||
|
}
|
||||||
|
if (typeof WScript !== "undefined") {
|
||||||
|
WScript.echo(" * " + message)
|
||||||
|
}
|
||||||
|
this._messages.push(message);
|
||||||
|
params.message = message;
|
||||||
|
} else if (typeof args[0] === "object") {
|
||||||
|
if ('message' in args[0]) {
|
||||||
|
if (typeof type !== "undefined") {
|
||||||
|
message += (type + ": " + args[0].message);
|
||||||
|
} else {
|
||||||
|
message += args[0].message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof WScript !== "undefined") {
|
||||||
|
WScript.echo(" * " + message);
|
||||||
|
}
|
||||||
|
this._messages.push(args[0].message);
|
||||||
|
for (var k in args[0]) {
|
||||||
|
params[k] = args[0][k];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this._messages.push(msg);
|
|
||||||
|
|
||||||
// after calling echo
|
// after calling echo
|
||||||
if (['error', 'info', 'warn'].indexOf(type) > -1 && typeof this._echoCallback === "function") {
|
if (['error', 'info', 'warn'].indexOf(type) > -1 && typeof this._echoCallback === "function") {
|
||||||
this._echoCallback(this);
|
this._echoCallback(params);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
assert: function(assertion) {
|
assert: function(assertion) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user