An alias for [waitAndEnter].
alias for waitForData
alias for waitForDataAndEnter
alias for waitForDataAndWrite
Configuration options of the current instance. Driver is configured on start but options can be changed later while is running.
alias for waitUntil
this error occurs when unser calls waitUntil* method with an interval greater than timeout
this error occurs on waitUntil* methods timeouts
Cleans the data buffer. Useful for making sure that the next data chunk is independent from current state.
destroy current terminal
Will write given text and then press ENTER. Just like write but appending '\r'
the string to enter
An alias for [enterAndWaitForData] but it will always resolve as string or throw an error otherwise.
same as in waitForData
same as in waitForData
same as in waitForData
same as in waitForData
By default waitUntil (and all wait* methods) will reject the promise on timeout. Set this to false so they resolve the promise with false value instead
same as in waitForData
get all the data collected from start
get information about all commands run in this driver instance. Will only work when options.debug===true
Optional get data from given time
Get data printed after given timestamp
return information about all the commands and state of this driver instance. commandHistory only available when options.debug===true
same as getDataFromLastWrite but applying strip.
Optional get data from given time
Resizes the dimensions of the pty.
THe number of columns to use.
The number of rows to use.
Starts the client with given options. Will spawn a new terminal
strips ANSI codes from a string. From https://github.com/xpl/ansicolor/blob/master/ansicolor.js
a string containing ANSI escape codes.
clean string.
An alias for [waitForData] but it will always resolve as string or throw an error otherwise.
An alias for [waitForDataAndEnter] but it will always resolve as string or throw an error otherwise.
Wait until new data matches given predicate. If not predicate is given will return the next data chunk that comes. Based on waitUntil
condition stdout must comply with in other to stop waiting for. If none it will wait until next data chunk is received. If function that's the predicate function the data must comply with. If string, the predicate will be that new data contains this string
wait timeout in ms
wait interval in ms
if provided it will ork with data after that given timestamp. By default this timestamp is the last write()'s
By default waitUntil (and all wait* methods) will reject the promise on timeout. Set this to false so they resolve the promise with false value instead
resolved with the matched data or rejected if no data comply with predicate before timeout
same as in waitForData
same as in waitForData
same as in waitForData
same as in waitForData
By default waitUntil (and all wait* methods) will reject the promise on timeout. Set this to false so they resolve the promise with false value instead
same as in waitForData
same as in waitForData
same as in write
same as in waitForData
same as in waitForData
same as in waitForData
By default waitUntil (and all wait* methods) will reject the promise on timeout. Set this to false so they resolve the promise with false value instead
same as in waitForData
Return a promise resolved after given number of milliseconds
will resolve the promise only when given number of milliseconds passed
the more generic wait* method on which all the others are based. Returns a promise that is resolved only when given predicate is fulfilled or rejected if timeout ms passes. THe implementation will be calling the predicate function like polling each interval [[waitInterval]] milliseconds.
a function that if return a truthy value will stop the polling
default value is [[waitTimeout]]
default value is [[waitInterval]]
By default waitUntil (and all wait* methods) will reject the promise on timeout. Set this to false so they resolve the promise with false value instead
A promise resolved with the return value of the predicate if it ever return truthy or in other case if the predicate never returns truthy in given timeout it will be rejected unless rejectOnTimeout===false in which case the promise is resolved with false
Writes given text in the terminal
number of milliseconds after which resolve write / enter promise. Default: 0
same as in waitForData
same as in waitForData
same as in waitForData
same as in waitForData
By default waitUntil (and all wait* methods) will reject the promise on timeout. Set this to false so they resolve the promise with false value instead
same as in waitForData
Tries to represent a predicate as a string. It accept functions, strings and [WaitForDataOptions]
Generated using TypeDoc
Usage example:
import { Driver q} from 'cli-driver' const client = new Driver() const options = {cwd: '/home/sg/myproject', noSilent: true} client.start() client.enter('ls') // now we wait until package.json is printed in stdout const data = await client.waitForData(data => data.includes('package.json'))
The options are documented DriverOptions
All methods return promises, so you can use async/await as in the previous example or then().catch().
Emit "data", "exit" and "start" events