Giter VIP home page Giter VIP logo

local-shell's Introduction

Local Shell

Local shell is a util to manage shell commands in asynchronous way like it's executed remotely. It has the same interface as Ssh-Shell to simplify usage.

Installation

Install via npm

npm i local-shell

Example

Example of variable usage:

const LocalShell = require('local-shell');
const fs = require('fs');

const shell = new LocalShell({
    cwd: process.cwd(),
});

shell.set('NAME', 'World');
shell.exec('echo Hello $NAME')
.then(result => {
    var {code, io} = result;
    if (code) {
        throw new Error('Exit code is ' + code);
    }

    console.log(io.toString()); // -> Hello World
});

API

exec(cmd:String) -> Promise<{code,io},Error>

Execute command and return promised Result object.

open()

Added for compatibility with SshShell

Start session. Emit open event.

close()

Added for compatibility with SshShell

Stop session. Emit close event.

uploadFile(source:String, [dest:String]) -> Promise(<null,Error>)

Upload file from source to destination. Destination is resolving from cwd value. If destination not set than it replaces with source's filename.

uploadBuffer(source:Buffer, dest:string) -> Promise(<null,Error>)

Upload data from buffer to the server.

downloadFile(source:String, [dest:String])

Download file from source into destination. If destination not set than it replaces with source's filename.

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.