execa
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
cross-spawn | 7.0.3 | 7.3 kB | MIT | prod | |
get-stream | 5.2.0 | 4.25 kB | MIT | prod | |
human-signals | 1.1.1 | 11.59 kB | Apache-2.0 | prod | |
is-stream | 2.0.1 | 2.17 kB | MIT | prod | |
merge-stream | 2.0.0 | 2.21 kB | MIT | prod | |
npm-run-path | 4.0.1 | 2.91 kB | MIT | prod | |
onetime | 5.1.2 | 2.68 kB | MIT | prod | |
signal-exit | 3.0.7 | 3.76 kB | ISC | prod | |
strip-final-newline | 2.0.0 | 1.66 kB | MIT | prod |
Execa is a JavaScript package designed to improve the methods of Node.js's child_process, making it easier for developers to work with process execution. Some key features include a promise interface, improved Windows support, execution of locally installed binaries without the need for npx, and a plethora of convenience methods for handling process input and output.
To use execa, start by installing the package using npm with the command npm install execa
. Below are some examples of how you can use execa:
// Using Promise Interface
import {execa} from 'execa';
const {stdout} = await execa('echo', ['unicorns']);
console.log(stdout); //=> 'unicorns'
// Using Scripts Interface
import {$} from 'execa';
const branch = await $`git branch --show-current`;
await $`dep deploy --branch=${branch}`;
// Handling Errors
import {execa} from 'execa';
try {
await execa('unknown', ['command']);
} catch (error) {
console.log(error);
}
// Graceful termination
const subprocess = execa('node');
setTimeout(() => {
subprocess.kill('SIGTERM', {
forceKillAfterTimeout: 2000
});
}, 1000);
These are simple use cases. To fully benefit from execa, review more advanced options and features in the usage documentation.
The comprehensive documentation for execa can be found on the GitHub page. The readme file includes all the details about installation, usage examples, options, and the API. It is designed as a complete guide, providing users with everything they need to know about the package, how it works, and how to use it effectively.