Socket
Socket
Sign inDemoInstall

bash-fool

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bash-fool

run a sequence of bash commands as specified by a json


Version published
Weekly downloads
7
decreased by-41.67%
Maintainers
1
Weekly downloads
 
Created
Source

run a sequence of bash commands as specified by a json

codecov Version Downloads/week License

Geenee Template

Why

Frequently you need to have a cli execute several commands. The tools execa and listr make this easy, but why go to the trouble of repeating the same boilerplate each time?

What

A function that generates a listr for execution of a set of bash commands using execa. You just pass in an array of commands and a listr is generated for it. You can also have:

  • targetDir a string indicating the directory that you can use in commands. Anywhere that you use a $codeDir placeholder, it will be dynamically replaced by targetDir.
  • session an object that lets you dynamically replace other strings in your commands. You must insert a key keyName into session, and then you can use it by placing into a command specification that string __session.keyName__. For instance, __session.lastName__ could be used in a command, and session could be `{lastName: 'jones'}.

Usage

First, install the package:

npm i bash-fool

Here is a sample usage:

const bashFool = require('bash-fool')

const commands = [
  {
    'title': 'echo a string',
    'file': 'echo',
    'arguments': [
      'this is echoed: __session:echoedString',
    ],
  },
  {
    title: 'more nothing',
    file: 'echo',
    arguments: [
      'second echoed function',
    ],
  },
]

const echoedString = 'foobar'
const session = { echoedString }

const targetDir = 'nonexistent'

(async () => {
  let listr = await bashFool(commands, targetDir, session)
  await listr.run() 
     // will echo: `this is echoed: foobar` 
     // and then: `second echoed function` 
})()

Keywords

FAQs

Package last updated on 27 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc