Execa
(moved to `tunnckoCore/opensource` as `@tunnckocore/execa`) Thin layer on top of `execa` that allows executing multiple commands in parallel or in sequence
Install / Use
/learn @tunnckoCoreLabs/ExecaREADME
@tunnckocore/execa
[![License][license-img]][license-url]
Thin layer on top of [execa][] that allows executing multiple commands in parallel or in sequence
Please consider following this project's author, Charlike Mike Reagent, and :star: the project to show your :heart: and support.
<div id="thetop"></div>[![Code style][codestyle-img]][codestyle-url] [![CircleCI linux build][linuxbuild-img]][linuxbuild-url] [![CodeCov coverage status][codecoverage-img]][codecoverage-url] [![DavidDM dependency status][dependencies-img]][dependencies-url] [![Renovate App Status][renovateapp-img]][renovateapp-url] [![Make A Pull Request][prs-welcome-img]][prs-welcome-url] [![Semantically Released][new-release-img]][new-release-url]
If you have any how-to kind of questions, please read the Contributing Guide and Code of Conduct documents.
For bugs reports and feature requests, [please create an issue][open-issue-url] or ping
@tunnckoCore at Twitter.
[![Become a Patron][patreon-img]][patreon-url] [![Conventional Commits][ccommits-img]][ccommits-url] ![NPM Downloads Weekly][downloads-weekly-img] ![NPM Downloads Monthly][downloads-monthly-img] ![NPM Downloads Total][downloads-total-img] [![Share Love Tweet][shareb]][shareu]
Project is semantically & automatically released on CircleCI with [new-release][] and its New Release GitHub App.
<!-- Logo when needed: <p align="center"> <a href="https://github.com/tunnckoCoreLabs/execa"> <img src="./media/logo.png" width="85%"> </a> </p> -->Table of Contents
(TOC generated by verb using markdown-toc)
Install
This project requires Node.js >=10.13.0. Install it using
yarn or npm.
We highly recommend to use Yarn when you think to contribute to this project.
$ yarn add @tunnckocore/execa
API
<!-- docks-start -->Generated using docks.
src/index.js
.exec
Uses [execa][] v2, execa.command() method.
As stated there, think of it as mix of child_process's .execFile and .spawn.
It is pretty similar to the .shell method too, but only visually because
it does not uses the system's shell, meaning it does not have access to
the system's environment variables.
It also can accept array of multiple strings of commands that will be executed in series.
Params
cmds{string|Array<string>} a commands to execute, if array of strings executes them seriallyopts{object} directly passed to [execa][] and so tochild_process
Returns
Promiseresolved or rejected promises
Examples
import { exec } from '@tunnckocore/execa';
// or
// const { exec } = require('@tunnckocore/execa');
async function init () {
await exec('echo "hello world"', { stdio: 'inherit' });
// executes in series
await exec([
'prettier-eslint --write foobar.js',
'eslint --format codeframe foobar.js --fix'
], { stdio: 'inherit', preferLocal: true });
}
init();
.shell
Same as .exec method, but also can accept an array of multiple
commands that will be executed in the system's shell, meaning that
it can access the system's environment variables from the command.
Params
cmds{string|Array<string>} a commands to execute, if array of strings executes them seriallyopts{object} directly passed toexeca.shellmethod.
Returns
Promiseresolved or rejected promises
Examples
import { shell } from '@tunnckocore/execa';
// or
// const { shell } = require('@tunnckocore/execa');
async function init () {
// executes in series
await shell([
'echo unicorns',
'echo "foo-$HOME-bar"',
'echo dragons'
], { stdio: 'inherit' });
// exits with code 3
try {
await shell([
'exit 3',
'echo nah'
]);
} catch (er) {
console.error(er);
// => {
// message: 'Command failed: /bin/sh -c exit 3'
// killed: false,
// code: 3,
// signal: null,
// cmd: '/bin/sh -c exit 3',
// stdout: '',
// stderr: '',
// timedOut: false
// }
}
}
init();
execa
Same as [execa][]'s default export, see its documentation.
<!-- docks-end -->See Also
Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your existance!
- @tunnckocore/scripts: Universal and minimalist scripts & tasks runner. | homepage
- asia: Blazingly fast, magical and minimalist testing framework, for Today and… more | homepage
- charlike: Small, fast and streaming project scaffolder with support for hundreds… more | homepage
- docks: Extensible system for parsing and generating documentation. It just freaking… more | homepage
- execa: A better
child_process| homepage
Contributing
Follow the Guidelines
Please read the Contributing Guide and Code of Conduct documents for advices.
For bugs reports and feature requests, [please create an issue][open-issue-url] or ping
@tunnckoCore at Twitter.
Support the project
[Become a Partner or Sponsor?][patreon-url] :dollar: Check the Partner, Sponsor or Omega-level tiers! :tada: You can get your company logo, link & name on this file. It's also rendered on package page in npmjs.com and yarnpkg.com sites too! :rocket:
Not financial support? Okey! Pull requests, stars and all kind of contributions are always welcome. :sparkles:
OPEN Open Source
This project is following OPEN Open Source model
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is built on collective efforts and it's not strongly guarded by its founders.
There are a few basic ground-rules for its contributors
- Any significant modifications must be subject to a pull request to get feedback from other contributors.
- Pull requests to get feedback are encouraged for any other trivial contributions, but are not required.
- Contributors should attempt to adhere to the prevailing code-style and development workflow.
Wonderful Contributors
Thanks to the hard work of these wonderful people this project is alive! It follows the
all-contributors specification.
Don't hesitate to add yourself to that list if you have made any contribution! ;) See how,
here.
| <img src="https://avatars3.githubusercontent.com/u/5038030?v=4" width="120px;"/><br /><sub><b>Charlike Mike Reagent</b></sub><br />💻 📖 💬 👀 🔍 | | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->Consider showing your support to them. :sparkling_heart:
License
Copyright (c) 2017-present, Charlike Mike Reagent <mameto2011@gmail.com> & contributors.
Released under the [Apache-2.0 License][license-url].
