forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
50,897 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,8 @@ Properties | |
*~ | ||
|
||
# test folder | ||
!_tests/* | ||
!_tests/* | ||
!_tests/*.js | ||
!_tests/*/*.js | ||
!_tests/*/*/*.js | ||
!_tests/*/*/*/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var ExecResult = (function () { | ||
function ExecResult() { | ||
this.stdout = ""; | ||
this.stderr = ""; | ||
} | ||
return ExecResult; | ||
})(); | ||
var WindowsScriptHostExec = (function () { | ||
function WindowsScriptHostExec() { } | ||
WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) { | ||
var result = new ExecResult(); | ||
var shell = new ActiveXObject('WScript.Shell'); | ||
try { | ||
var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' ')); | ||
} catch (e) { | ||
result.stderr = e.message; | ||
result.exitCode = 1; | ||
handleResult(result); | ||
return; | ||
} | ||
while(process.Status != 0) { | ||
} | ||
result.exitCode = process.ExitCode; | ||
if(!process.StdOut.AtEndOfStream) { | ||
result.stdout = process.StdOut.ReadAll(); | ||
} | ||
if(!process.StdErr.AtEndOfStream) { | ||
result.stderr = process.StdErr.ReadAll(); | ||
} | ||
handleResult(result); | ||
}; | ||
return WindowsScriptHostExec; | ||
})(); | ||
var NodeExec = (function () { | ||
function NodeExec() { } | ||
NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) { | ||
var nodeExec = require('child_process').exec; | ||
var result = new ExecResult(); | ||
result.exitCode = null; | ||
var cmdLine = filename + ' ' + cmdLineArgs.join(' '); | ||
var process = nodeExec(cmdLine, function (error, stdout, stderr) { | ||
result.stdout = stdout; | ||
result.stderr = stderr; | ||
result.exitCode = error ? error.code : 0; | ||
handleResult(result); | ||
}); | ||
}; | ||
return NodeExec; | ||
})(); | ||
var Exec = (function () { | ||
var global = Function("return this;").call(null); | ||
if(typeof global.ActiveXObject !== "undefined") { | ||
return new WindowsScriptHostExec(); | ||
} else { | ||
return new NodeExec(); | ||
} | ||
})(); |
Oops, something went wrong.