Socket
Socket
Sign inDemoInstall

execa

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

execa - npm Package Compare versions

Comparing version 7.2.0 to 8.0.1

52

index.d.ts

@@ -15,3 +15,23 @@ import {type Buffer} from 'node:buffer';

export type CommonOptions<EncodingType> = {
type EncodingOption =
| 'utf8'
// eslint-disable-next-line unicorn/text-encoding-identifier-case
| 'utf-8'
| 'utf16le'
| 'utf-16le'
| 'ucs2'
| 'ucs-2'
| 'latin1'
| 'binary'
| 'ascii'
| 'hex'
| 'base64'
| 'base64url'
| 'buffer'
| null
| undefined;
type DefaultEncodingOption = 'utf8';
type BufferEncodingOption = 'buffer' | null;
export type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
/**

@@ -180,3 +200,3 @@ Kill the spawned process when the parent process exits unless either:

/**
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.

@@ -211,6 +231,4 @@ @default 'utf8'

When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `false`.
When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `true`.
*Requires Node.js 16 or later.*
@example

@@ -261,3 +279,3 @@ ```

export type Options<EncodingType = string> = {
export type Options<EncodingType extends EncodingOption = DefaultEncodingOption> = {
/**

@@ -278,3 +296,3 @@ Write some input to the `stdin` of your binary.

export type SyncOptions<EncodingType = string> = {
export type SyncOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
/**

@@ -295,3 +313,3 @@ Write some input to the `stdin` of your binary.

export type NodeOptions<EncodingType = string> = {
export type NodeOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
/**

@@ -636,6 +654,6 @@ The Node.js executable to use.

arguments?: readonly string[],
options?: Options<null>
options?: Options<BufferEncodingOption>
): ExecaChildProcess<Buffer>;
export function execa(file: string, options?: Options): ExecaChildProcess;
export function execa(file: string, options?: Options<null>): ExecaChildProcess<Buffer>;
export function execa(file: string, options?: Options<BufferEncodingOption>): ExecaChildProcess<Buffer>;

@@ -710,3 +728,3 @@ /**

arguments?: readonly string[],
options?: SyncOptions<null>
options?: SyncOptions<BufferEncodingOption>
): ExecaSyncReturnValue<Buffer>;

@@ -716,3 +734,3 @@ export function execaSync(file: string, options?: SyncOptions): ExecaSyncReturnValue;

file: string,
options?: SyncOptions<null>
options?: SyncOptions<BufferEncodingOption>
): ExecaSyncReturnValue<Buffer>;

@@ -743,3 +761,3 @@

export function execaCommand(command: string, options?: Options): ExecaChildProcess;
export function execaCommand(command: string, options?: Options<null>): ExecaChildProcess<Buffer>;
export function execaCommand(command: string, options?: Options<BufferEncodingOption>): ExecaChildProcess<Buffer>;

@@ -763,3 +781,3 @@ /**

export function execaCommandSync(command: string, options?: SyncOptions): ExecaSyncReturnValue;
export function execaCommandSync(command: string, options?: SyncOptions<null>): ExecaSyncReturnValue<Buffer>;
export function execaCommandSync(command: string, options?: SyncOptions<BufferEncodingOption>): ExecaSyncReturnValue<Buffer>;

@@ -799,3 +817,3 @@ type TemplateExpression =

(options: Options): Execa$;
(options: Options<null>): Execa$<Buffer>;
(options: Options<BufferEncodingOption>): Execa$<Buffer>;
(

@@ -946,5 +964,5 @@ templates: TemplateStringsArray,

arguments?: readonly string[],
options?: NodeOptions<null>
options?: NodeOptions<BufferEncodingOption>
): ExecaChildProcess<Buffer>;
export function execaNode(scriptPath: string, options?: NodeOptions): ExecaChildProcess;
export function execaNode(scriptPath: string, options?: NodeOptions<null>): ExecaChildProcess<Buffer>;
export function execaNode(scriptPath: string, options?: NodeOptions<BufferEncodingOption>): ExecaChildProcess<Buffer>;

@@ -13,3 +13,2 @@ import {Buffer} from 'node:buffer';

const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
const DOUBLE_QUOTES_REGEXP = /"/g;

@@ -21,3 +20,3 @@ const escapeArg = arg => {

return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
return `"${arg.replaceAll('"', '\\"')}"`;
};

@@ -36,3 +35,3 @@

// Allow spaces to be escaped by a backslash if not meant as a delimiter
const previousToken = tokens[tokens.length - 1];
const previousToken = tokens.at(-1);
if (previousToken && previousToken.endsWith('\\')) {

@@ -86,3 +85,3 @@ // Merge previous token with current one

...tokens.slice(0, -1),
`${tokens[tokens.length - 1]}${nextTokens[0]}`,
`${tokens.at(-1)}${nextTokens[0]}`,
...nextTokens.slice(1),

@@ -89,0 +88,0 @@ ];

import os from 'node:os';
import onExit from 'signal-exit';
import {onExit} from 'signal-exit';

@@ -4,0 +4,0 @@ const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;

import {createReadStream, readFileSync} from 'node:fs';
import {setTimeout} from 'node:timers/promises';
import {isStream} from 'is-stream';
import getStream from 'get-stream';
import getStream, {getStreamAsBuffer} from 'get-stream';
import mergeStream from 'merge-stream';

@@ -82,2 +83,5 @@

// Wait for the `all` stream to receive the last chunk before destroying the stream
await setTimeout(0);
stream.destroy();

@@ -97,9 +101,19 @@

if (encoding) {
return getStream(stream, {encoding, maxBuffer});
// eslint-disable-next-line unicorn/text-encoding-identifier-case
if (encoding === 'utf8' || encoding === 'utf-8') {
return getStream(stream, {maxBuffer});
}
return getStream.buffer(stream, {maxBuffer});
if (encoding === null || encoding === 'buffer') {
return getStreamAsBuffer(stream, {maxBuffer});
}
return applyEncoding(stream, maxBuffer, encoding);
};
const applyEncoding = async (stream, maxBuffer, encoding) => {
const buffer = await getStreamAsBuffer(stream, {maxBuffer});
return buffer.toString(encoding);
};
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)

@@ -106,0 +120,0 @@ export const getSpawnedResult = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {

{
"name": "execa",
"version": "7.2.0",
"version": "8.0.1",
"description": "Process execution for humans",

@@ -14,5 +14,8 @@ "license": "MIT",

"type": "module",
"exports": "./index.js",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": "^14.18.0 || ^16.14.0 || >=18.0.0"
"node": ">=16.17"
},

@@ -47,4 +50,4 @@ "scripts": {

"cross-spawn": "^7.0.3",
"get-stream": "^6.0.1",
"human-signals": "^4.3.0",
"get-stream": "^8.0.1",
"human-signals": "^5.0.0",
"is-stream": "^3.0.0",

@@ -54,16 +57,16 @@ "merge-stream": "^2.0.0",

"onetime": "^6.0.0",
"signal-exit": "^3.0.7",
"signal-exit": "^4.1.0",
"strip-final-newline": "^3.0.0"
},
"devDependencies": {
"@types/node": "^18.13.0",
"@types/node": "^20.4.0",
"ava": "^5.2.0",
"c8": "^7.12.0",
"get-node": "^13.5.0",
"c8": "^8.0.1",
"get-node": "^14.2.0",
"is-running": "^2.1.0",
"p-event": "^5.0.1",
"p-event": "^6.0.0",
"path-key": "^4.0.0",
"tempfile": "^4.0.0",
"tsd": "^0.25.0",
"xo": "^0.54.2"
"tempfile": "^5.0.0",
"tsd": "^0.28.1",
"xo": "^0.55.0"
},

@@ -70,0 +73,0 @@ "c8": {

@@ -25,3 +25,3 @@ <picture>

<br>
<a href="https://transloadit.com">
<a href="https://transloadit.com?utm_source=sindresorhus&utm_medium=referral&utm_campaign=sponsorship&utm_content=execa">
<picture>

@@ -686,3 +686,3 @@ <source width="360" media="(prefers-color-scheme: dark)" srcset="https://sindresorhus.com/assets/thanks/transloadit-logo-dark.svg">

Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.

@@ -716,6 +716,4 @@ #### timeout

When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `false`.
When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `true`.
*Requires Node.js 16 or later.*
#### windowsVerbatimArguments

@@ -722,0 +720,0 @@

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