A tiny spawn wrapper for Node.js

Overview

tinysh

A tiny spawn wrapper for Node.js.

const {ls, curl} = require('tinysh')

const list = ls('-la').trim().split('\n')

const resp = curl('https://medv.io')

Usage

npm i tinysh

Import any binary you would like to call. Use it like a function.

const {cat} = require('tinysh')

const content = cat('README.md')

To get exit code or stderr, use .status or .stderr.

const {git} = require('tinysh')

console.log(git('pull').status)

To pass options to the spawn, bind to an options object.

const {tee} = require('tinysh')

tee.call({input: 'Hello, world!'}, 'file.txt')

License

MIT

You might also like...

An open source API wrapper for TechHost API.

TechHost API Wrapper An open source API wrapper for TechHost API. Badges Installation Install techhost-api-wrapper with npm. npm install techhost-api-

Jun 23, 2022

A simple PureScript wrapper for React

purescript-thermite purescript-thermite is a PureScript wrapper for purescript-react. It does not provide all of the functionality of React, but inste

Dec 16, 2022

Thin wrapper around Rant-Lang for Obsidian.md

Thin wrapper around Rant-Lang for Obsidian.md

Obsidian Rant-Lang Thin wrapper around the Rant language Rust crate to be used in Obsidian. "Rant is a high-level procedural templating language with

Jul 12, 2022

A thin wrapper around arweave-js for versioned permaweb document management.

🎁 ar-wrapper A thin wrapper around arweave-js for versioned permaweb document management. Helps to abstract away complexity for document storage for

May 12, 2022

Programmers House api official wrapper

programmershouse-wrapper Programmers House api official wrapper Install: npm install programmershouse-wrapper Example of using: With .then //importing

Mar 23, 2022

A simple nodejs module which is wrapper around solc that allows you to compile Solidity code

A simple nodejs module which is wrapper around solc that allows you to compile Solidity code

Simple Solidity Compiler It's a simple nodejs module which is wrapper around solc that allows you to compile Solidity code and get the abi and bytecod

Feb 21, 2022

An iterator wrapper that supports Rust-style chaining

Riter (in development) An iterator wrapper that supports Rust-style chaining Install TODO: This package is not yet available. Once it's mature enough,

Mar 3, 2022

A nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory

A nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory

This package is a nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory. Thanks to @derrickreimer for this framework agnostic library â€ïžâ€đŸ”„.

Aug 18, 2022

An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.

An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.

CQRS Wechaty An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve

Mar 23, 2022
Comments
  • Specify an encoding?

    Specify an encoding?

    I love the idea behind this library!

    How about implementing the Proxy like this:

    const {spawnSync} = require('child_process');
    module.exports = new Proxy(
      {},
      {
        get: (_, bin) => (...args) => {
          return spawnSync(bin, args, {encoding: 'utf-8'});
        },
      }
    )
    

    A benefit of specifying an encoding is that you don’t need this code anymore: Object.assign(new String(out.stdout), out)

    Are you using {...this} so that users can change the options of spawnSync()? Then I’d prefer a solution that doesn’t mutate a global object – maybe:

    function createShell(userOptions = {}) {
      const options = {encoding: 'utf-8', ...userOptions};
      return new Proxy(
        {},
        {
          get: (_, bin) => (...args) => {
            return spawnSync(bin, args, {encoding: 'utf-8'});
          },
        }
      );
    }
    
    const sh = createShell();
    console.log(sh.ls('-la'));
    
    opened by rauschma 10
  • feat: add proxy factory

    feat: add proxy factory

    const {git, npm} = require('tinysh')({ cwd: 'foo/packages/bar' })
    
    git('add .')
    git('commit -m "foo"')
    git('push origin HEAD:refs/heads/master')
    
    npm('publish')
    

    instead of

    const {git, npm} = require('tinysh')
    
    git.call({cwd}, 'add .')
    git.call({cwd}, commit -m "foo"')
    git.call({cwd}, 'push origin HEAD:refs/heads/master')
    
    npm.call({cwd}, 'publish')
    
    opened by antongolub 1
Owner
Anton Medvedev
SRE at Google
Anton Medvedev
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Tiny Telegra.ph API wrapper for Deno

Telegra.ph API wrapper for Deno ?? This is a tiny Telegra.ph API wrapper for Deno written in TypeScript. All methods as listed here are available. See

Dunkan 9 Jul 28, 2022
Shopee Affiliate Wrapper for Node.js

shpee Javascript Wrapper for Shopee Affiliate API Installation Use the package manager npm to install shpee. npm install shpee Usage # shopee_client.j

Ngalim Siregar 5 Dec 1, 2022
A node wrapper for the Netcup CCP API.

Netcup-node A node wrapper for the Netcup CCP API. Current support only JSON Rest API, no SOAP yet auto auth handling with support to use custom auth

Direnc Timur 7 Dec 22, 2022
An ADB wrapper made in node js. For mobile debugging

Adb-Wrapper An awesome ADB wrapper made in node js to use adb just with functions. · Report Bug · Request Feature Table of Contents About The Project

Amir Alam 4 Dec 17, 2022
An unofficial wrapper for the Bloxlink API using Node.js

Bloxlink API wrapper ?? Bloxlink-sdk is a simple, easy to use API wrapper for Bloxlinks API using Node.js. Anyone who can use code should be fairly co

Callum Sequoia 3 Oct 21, 2022
Tiny and powerful JavaScript full-text search engine for browser and Node

MiniSearch MiniSearch is a tiny but powerful in-memory fulltext search engine written in JavaScript. It is respectful of resources, and it can comfort

Luca Ongaro 2k Jan 3, 2023
A tiny blockchain node for browsers.

UBI Chain A very tiny blockchain for browsers. Features Spin up a node from a browser. One node per human via Proof of Humanity UBI for gas and fees.

Democracy Earth Foundation 15 Sep 29, 2022
Node 18's node:test, as a node module

node-core-test This is a user-land port of node:test, the experimental test runner introduced in Node.js 18. This module makes it available in Node.js

Julian Gruber 62 Dec 15, 2022