mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-13 12:20:12 +08:00
add nexpect
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/// <reference path="./nexpect.d.ts" />
|
||||
|
||||
import nexpect = require('nexpect');
|
||||
|
||||
nexpect.spawn("echo", ["hello"])
|
||||
.expect("hello")
|
||||
.run((err, stdout, exitcode) => {
|
||||
if (!err) {
|
||||
console.log("hello was echoed");
|
||||
}
|
||||
});
|
||||
|
||||
nexpect.spawn("ls -la /tmp/undefined", {stream: 'stderr'})
|
||||
.expect("No such file or directory")
|
||||
.run((err) => {
|
||||
if (!err) {
|
||||
console.log("checked that file doesn't exists");
|
||||
}
|
||||
});
|
||||
|
||||
nexpect.spawn("node --interactive")
|
||||
.expect(">")
|
||||
.sendline("console.log('testing')")
|
||||
.expect("testing")
|
||||
.sendline("process.exit()")
|
||||
.run((err) => {
|
||||
if (!err) {
|
||||
console.log("node process started, console logged, process exited");
|
||||
}
|
||||
else {
|
||||
console.log(err)
|
||||
}
|
||||
});
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for nexpect 0.4.2
|
||||
// Project: https://github.com/nodejitsu/nexpect
|
||||
// Definitions by: vvakame <http://github.com/vvakame>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "nexpect" {
|
||||
import child_process = require("child_process");
|
||||
|
||||
function spawn(command:string[], options?:ISpawnOptions):IChain;
|
||||
|
||||
function spawn(command:string, params?:any[], options?:ISpawnOptions):IChain;
|
||||
|
||||
function spawn(command:string, options?:ISpawnOptions):IChain;
|
||||
|
||||
interface IChain {
|
||||
expect(expectation:string):IChain;
|
||||
expect(expectation:RegExp):IChain;
|
||||
wait(expectation:string):IChain;
|
||||
wait(expectation:RegExp):IChain;
|
||||
sendline(line:string):IChain;
|
||||
sendEof():IChain;
|
||||
run(callback:(err:Error, output:string[], exit:any /* string | number */)=>void):child_process.ChildProcess;
|
||||
}
|
||||
|
||||
interface ISpawnOptions {
|
||||
cwd?:string;
|
||||
env?:any;
|
||||
ignoreCase?:any;
|
||||
stripColors?:any;
|
||||
stream?:any;
|
||||
verbose?:any;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user