expected-write

0.0.1 • Public • Published

Expected-Write

Expected-Write is a tiny Promise-based expect-and-write library. It's super simple to get going with it and it works on all kinds of streams and child processes.

SSH Example

var SSHDriver = require('node-ssh')
var ExpectedWrite = require('expected-write')
var SSH = new SSHDriver({
  host: 'localhost',
  username: 'steel',
  privateKey: '/home/steel/.ssh/id_rsa'
})
SSH.connect().then(function(){
  return SSH.requestShell()
}).then(function(SSHShell){
  var E = new ExpectedWrite(SSHShell)
  E.write("sudo echo test\n").expect('[sudo] password')
    .then(function(Content)){
      console.log(Content) // [sudo] password for steel:
      E.write("mySecretPassword")
      return E.expect("test")
    })
    .then(function(Info){
      E.end()
    })
})

API

enum StreamType { stdout, stderr, both }
class ExpectedWrite extends EventEmitter{
  expect(toExpect: String, expectedStream: StreamType): Promise
  write(Content: String): this
  end(?Content: String): Promise
  onEnd(): Promise
}

License

This project is licensed under the terms of MIT License. See the License file for more info.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    1

Package Sidebar

Install

npm i expected-write

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • steelbrain