1.3.2 • Published 3 years ago

puff-pastry v1.3.2

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

puff-pastry

npm CI Status dependencies Status devDependencies Status

Scaffolding for CLI tools

Usage

Install puff-pastry by running:

yarn add puff-pastry

Use it to create command-line executables like so:

#!/usr/bin/env node
import run from 'puff-pastry'

run('./cli.mjs', {
  flags: ['--loader', 'hot-esm']
})
export default async function({cwd, env, argv, log}) {
  log('Hello World!')
}

run() takes the path to a CLI entry function and calls it with an object containing:

  • cwd: The current working directory
  • env: An object containing the environment variables
  • argv: The command-line arguments
  • stdout: A stream that writes to STDOUT
  • stderr: A stream that writes to STDERR

Also, if a .env.yml file is present in the current working directory, it is read and added to env. See vinsonchuong/envdotyml.

Encapsulating a CLI into a function that takes arguments instead of relying on the process global object allows for:

  • Easier unit testing
  • Easier composition of CLI tools from JavaScript
1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago