@ionic/utils-subprocess

  • Version 2.1.8
  • Published
  • 21.9 kB
  • 8 dependencies
  • MIT license

Install

npm i @ionic/utils-subprocess
yarn add @ionic/utils-subprocess
pnpm add @ionic/utils-subprocess

Overview

Subprocess utils for NodeJS

Index

Variables

variable ERROR_COMMAND_NOT_FOUND

const ERROR_COMMAND_NOT_FOUND: string;

    variable ERROR_NON_ZERO_EXIT

    const ERROR_NON_ZERO_EXIT: string;

      variable ERROR_SIGNAL_EXIT

      const ERROR_SIGNAL_EXIT: string;

        variable TILDE_PATH_REGEX

        const TILDE_PATH_REGEX: RegExp;

          Functions

          function convertPATH

          convertPATH: (path?: string) => string;
          • Prepare the PATH environment variable for use with subprocesses.

            If a raw tilde is found in PATH, e.g. ~/.bin, it is expanded. The raw tilde works in Bash, but not in Node's child_process outside of a shell.

            This is a utility method. You do not need to use it with Subprocess.

            Parameter path

            Defaults to process.env.PATH

          function expandTildePath

          expandTildePath: (p: string) => string;

            function findExecutables

            findExecutables: (
            program: string,
            { PATH, PATHEXT }?: WhichOptions
            ) => Promise<string[]>;
            • Find all instances of a program in PATH.

              If program contains a path separator, this function will merely return it inside an array.

              Parameter program

              A command name, such as ionic

            function fork

            fork: (
            modulePath: string,
            args?: readonly string[],
            options?: ForkOptions & Pick<SpawnOptions, 'stdio'>
            ) => any;

              function spawn

              spawn: (command: string, args?: readonly string[], options?: any) => any;

                function which

                which: (program: string, { PATH, PATHEXT }?: WhichOptions) => Promise<string>;
                • Find the first instance of a program in PATH.

                  If program contains a path separator, this function will merely return it.

                  Parameter program

                  A command name, such as ionic

                Classes

                class Subprocess

                class Subprocess {}

                  constructor

                  constructor(name: string, args: readonly string[], options?: SubprocessOptions);

                    property args

                    args: readonly string[];

                      property name

                      name: string;

                        property options

                        readonly options: any;

                          property path

                          protected readonly path?: string;

                            method bashify

                            bashify: ({
                            maskArgv0,
                            maskArgv1,
                            shiftArgv0,
                            }?: SubprocessBashifyOptions) => string;

                              method bashifyArg

                              bashifyArg: (arg: string) => string;

                                method combinedOutput

                                combinedOutput: () => Promise<string>;

                                  method maskArg

                                  maskArg: (arg: string) => string;

                                    method output

                                    output: () => Promise<string>;

                                      method run

                                      run: () => Promise<void> & { p: ChildProcess };

                                        method spawn

                                        spawn: () => any;

                                          class SubprocessError

                                          class SubprocessError extends Error {}

                                            constructor

                                            constructor(message: string);

                                              property code

                                              code?:
                                              | 'ERR_SUBPROCESS_COMMAND_NOT_FOUND'
                                              | 'ERR_SUBPROCESS_NON_ZERO_EXIT'
                                              | 'ERR_SUBPROCESS_SIGNAL_EXIT';

                                                property error

                                                error?: Error;

                                                  property exitCode

                                                  exitCode?: number;

                                                    property message

                                                    message: string;

                                                      property name

                                                      readonly name: string;

                                                        property output

                                                        output?: string;

                                                          property signal

                                                          signal?: string;

                                                            property stack

                                                            stack: string;

                                                              Interfaces

                                                              interface SubprocessBashifyOptions

                                                              interface SubprocessBashifyOptions {}

                                                                property maskArgv0

                                                                maskArgv0?: boolean;
                                                                • Mask file path to first argument.

                                                                  The first argument to subprocesses is the program name or path, e.g. /path/to/bin/my-program. If true, bashify() will return the program name without a file path, e.g. my-program.

                                                                  The default is true.

                                                                property maskArgv1

                                                                maskArgv1?: boolean;
                                                                • Mask file path to second argument.

                                                                  In some subprocesses, the second argument is a script file to run, e.g. node ./scripts/post-install. If true, bashify() will return the script name without a file path, e.g. node post-install.

                                                                  The default is false.

                                                                property shiftArgv0

                                                                shiftArgv0?: boolean;
                                                                • Remove the first argument from output.

                                                                  Useful to make a command such as node ./scripts/post-install appear as simply post-install.

                                                                  The default is false.

                                                                interface SubprocessOptions

                                                                interface SubprocessOptions extends SpawnOptions {}

                                                                  interface WhichOptions

                                                                  interface WhichOptions {}

                                                                    property PATH

                                                                    PATH?: string;

                                                                      property PATHEXT

                                                                      PATHEXT?: string;

                                                                        Package Files (1)

                                                                        Dependencies (8)

                                                                        Dev Dependencies (10)

                                                                        Peer Dependencies (0)

                                                                        No peer dependencies.

                                                                        Badge

                                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic/utils-subprocess.

                                                                        • Markdown
                                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ionic/utils-subprocess)
                                                                        • HTML
                                                                          <a href="https://www.jsdocs.io/package/@ionic/utils-subprocess"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>