3.2.0 • Published 8 months ago

@node-kit/extra.cp v3.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@node-kit/extra.cp

Some shared extra utilities for nodejs build-in child_process modules

NPM version Codacy Badge Test coverage npm download License

Sonar

Install

# use pnpm
$ pnpm install -D @node-kit/extra.cp

# use yarn
$ yarn add -D @node-kit/extra.cp

# use npm
$ npm install -D @node-kit/extra.cp

Usage

use import

import { execa, execaSync } from '@node-kit/extra.cp'

execa().then(() => {})

use require

const { execa, execaSync } = require('@node-kit/extra.cp')

execa().then(() => {})

API reference

1. execa & execaSync

make exec behave like execa

  • Usage: execa(file, args, options) & execaSync(file, args, options)
  • Parameters:
ParamDescriptionTypeOptional valueRequiredDefault value
fileThe name or path of the executable file to run.string-true-
argsList of string arguments.ReadonlyArray<string>-false-
optionsOptions for execFileobject-false-
  • Types:
import type {
  ExecFileOptions,
  ExecFileOptionsWithBufferEncoding,
  ExecFileOptionsWithStringEncoding,
  ExecFileSyncOptions,
  ExecFileSyncOptionsWithBufferEncoding,
  ExecFileSyncOptionsWithStringEncoding
} from 'node:child_process'
import type { ObjectEncodingOptions } from 'node:fs'

declare function execa(
  file: string,
  args?: ReadonlyArray<string> | undefined | null,
  options?:
    | ExecFileOptions
    | ((ObjectEncodingOptions & ExecFileOptions) | undefined | null)
    | ExecFileOptionsWithBufferEncoding
    | ExecFileOptionsWithStringEncoding
): Promise<{
  stdout: string | Buffer
  stderr: string | Buffer
}>

declare function execaSync(
  file: string,
  args?: ReadonlyArray<string>,
  options?:
    | ExecFileSyncOptions
    | ExecFileSyncOptionsWithBufferEncoding
    | ExecFileSyncOptionsWithStringEncoding
): string | Buffer
  • Demos:
  1. simple use
import { execa, execaSync } from '@node-kit/extra.cp'

execa().then(() => {})

Issues & Support

Please open an issue here.

License

MIT

3.2.0

8 months ago

3.1.1

10 months ago

3.1.0

10 months ago

3.0.0

10 months ago

3.0.0-beta.5

10 months ago

3.0.0-beta.4

10 months ago

3.0.0-beta.3

10 months ago