Skip to content

Frapwings/anyrun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anyrun

Transparent command execution library & command execution tool.

Requirement

  • node >= 0.10.x

Installation

$ npm install anyrun

Example

// local
anyrun()
  .run('uname -s', function (err, stdout, stderr) {
    if (err) {
      console.error('uname error: code = %d, signal = %s', err.code, err.signal);
      return;
    }
    console.log('uname done: ', stdout);
  })
  .run('echo "Hello world"', function (err, stdout, stderr) {
    console.log('echo done');
  });

// remote
anyrun()
  .ssh('host', 'example.com')
  .ssh('port', 2222)
  .run('uname -u', function (err, stdout, stderr) {
    console.log('uname done');
  })
  .run('echo "Hello world"', function (err, stdout, stderr) {
    console.log('echo done');
  })

API

anyrun()

Initialize a new AnyRun instance.

AnyRun#AnyRun()

Initialize a new AnyRun instance.

AnyRun#ssh(key, value)

Set ssh options.

  • key: the option key
  • value: the option value

AnyRun#run(cmd, [opts], cb)

Run command.

  • cmd: the command
  • opts: the options
  • cb: the cb(err, stdout, stderr) callback

AnyRun#done([cb])

Done ssh session.

  • cb: the cb(err) callback

Test

You must be prepared following before running the test.

  • setup Virtualbox
  • setup Vagrant
  • start Vagrant VM
  • setting sshd config (add __HOGE__ to AcceptEnv) on server, and restart
  • copy the private key genereted by Vagrant to test/fixtures/id_rsa.vagrant

When you're ready, run the following command:

    $ make test

License

MIT license.

See the LICENSE.

About

Transparent command runner library &command runner tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published