mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
add nexpect
This commit is contained in:
parent
65a465cdec
commit
0f4ef7ff85
@ -279,6 +279,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [mysql](https://github.com/felixge/node-mysql) (by [William Johnston](https://github.com/wjohnsto))
|
||||
* [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo))
|
||||
* [needle](https://github.com/tomas/needle) (by [San Chen](https://github.com/bigsan))
|
||||
* [nexpect](https://github.com/nodejitsu/nexpect) (by [vvakame](https://github.com/vvakame))
|
||||
* [noble](https://github.com/sandeepmistry/noble) (by [Seon-Wook Park](https://github.com/swook))
|
||||
* [nock](https://github.com/pgte/nock) (by [bonnici](https://github.com/bonnici))
|
||||
* [Node.js](http://nodejs.org/) (from TypeScript samples)
|
||||
|
||||
33
nexpect/nexpect-tests.ts
Normal file
33
nexpect/nexpect-tests.ts
Normal file
@ -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)
|
||||
}
|
||||
});
|
||||
35
nexpect/nexpect.d.ts
vendored
Normal file
35
nexpect/nexpect.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user