Giter Site home page Giter Site logo

exeq's Introduction

exeq

Excute shell commands in queue.

NPM version Build Status David Status NPM downloads


Install

$ npm install exeq --save

Usage

exeq()

exeq(
  'mkdir example',
  'rm -rf example'
);

Promise 2.0.0+

// promise
exeq(
  'mkdir example',
  'cd example',
  'touch README.md',
  'touch somefile',
  'rm somefile',
  'ls -l',
  'cd ..',
  'rm -rf example',
  'ls -l > output.txt'
).then(function() {
  console.log('done!');
}).catch(function(err) {
  console.log(err);
});

Array

exeq([
  'mkdir example',
  'rm -rf example'
]);

stdout & stderr

exeq(
  'echo 123',
  'echo 456',
  'echo 789'
).then(function(results) {
  console.log(results[0].stdout); // '123'
  console.log(results[1].stdout); // '456'
  console.log(results[2].stdout); // '789'
});
exeq(
  'not-existed-command'
).then(function(results) {
}).catch(function(err) {
  console.log(err); // { code: '127', stderr: ' ... ' }
});

change cwd

// cd command would change spawn cwd automatically
// create README.md in example
exeq(
  'mkdir example',
  'cd example',
  'touch README.md'
);

Kill the execution

var proc = exeq([
  'echo 1',
  'sleep 10',
  'echo 2'
]);
proc.q.kill();

Events

var proc = exeq([
  'echo 1',
  'echo 2'
]);

proc.q.on('stdout', function(data) {
  console.log(data);
});

proc.q.on('stderr', function(data) {
  console.log(data);
});

proc.q.on('killed', function(reason) {
  console.log(reason);
});

proc.q.on('done', function() {
});

proc.q.on('failed', function() {
});

Test

$ npm test

License

The MIT License (MIT)

Support on Beerpay

Hey dude! Help me out for a couple of ๐Ÿป!

Beerpay Beerpay

exeq's People

Contributors

afc163 avatar ibigbug avatar monkindey avatar popomore avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.