diff --git a/lib/std.js b/lib/std.js index eac9332..1fb78cb 100644 --- a/lib/std.js +++ b/lib/std.js @@ -430,6 +430,15 @@ function AsyncFunction(f, __filename) { this.runSynchronously = function() { return this.f.apply(null, arguments); }; + + if (typeof this.__filename === "string") { + this.__filename = __filename; + } else if (typeof WScript !== "undefined") { + this.__filename = (function(path) { + var pos = Math.max.apply(null, [path.lastIndexOf("\\"), path.lastIndexOf("/")]); + return (pos > -1 ? path.substring(pos + 1) : ""); + })(WScript.ScriptFullName); + } }; AsyncFunction.counter = 0; AsyncFunction.bind = function(exports, args) {