Giter Club home page Giter Club logo

exeggcute's Introduction

exeggcute

Version Downloads

A node.js module to make executing shell commands a breeze!

It simply wraps child_process.exec with a promise so there are zero dependencies besides node!

img

Installation

Use npm as usual to save the package to your dependencies:

npm install --save exeggcute

Usage

Windows (note the directory)

const exec = require('exeggcute').exec;
var dir = 'c:/code/';
var cmd = 'git clone https://github.com/styfle/exeggcute';
exec(cmd, dir);

Linux (note the directory)

const exec = require('exeggcute').exec;
var dir = '/code/';
var cmd = 'git clone https://github.com/styfle/exeggcute';
exec(cmd, dir);

ES6 Import (note the import)

import {exec} from 'exeggcute';
var dir = '/code/';
var cmd = 'git clone https://github.com/styfle/exeggcute';
exec(cmd, dir);

What's with the name?

The name exeggcute is named after the pokemon, Exeggcute. You can see more code/projects named after pokemon at repokemon.

Why did you make this?

I wanted to execute a chain of commands that reads nicely and not worry about syntax. The node core APIs do not use promises so it's easy to get into callback hell. exeggcute makes it easy to write a RESTful API that executes several commands in a row and fails if any one command in the chain fails.

Advanced Usage Example

Below is an example that mirrors code from the originRepo to the targetRepo. This is a hook that runs for each push of a branch or tag to the originRepo and will then push that branch/tag to the targetRepo.

hasDir(repoDir)
    .then(exists => {
        if (!exists) {
            return exec(`git clone ${originRepo}`, baseDir)
                .then(() => exec(`git remote add target ${targetRepo}`, repoDir))
        }
        return Promise.resolve(exists);
    })
    .then(() => exec(`git checkout ${branch}`, repoDir))
    .then(() => exec(`git pull origin ${branch}`, repoDir))
    .then(() => exec(`git push target ${branch}`, repoDir))
    .then(() => exec(`git pull origin --tags`, repoDir))
    .then(() => exec(`git push target --tags`, repoDir))
    .catch((err) => console.error('Oh no! ', err));

exeggcute's People

Contributors

styfle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

exeggcute's Issues

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.