shell.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /// <reference types="node" />
  2. import { Subprocess, SubprocessOptions, WhichOptions } from '@ionic/utils-subprocess';
  3. import { ChildProcess, SpawnOptions } from 'child_process';
  4. import { ILogger, IShell, IShellOutputOptions, IShellRunOptions, IShellSpawnOptions } from '../definitions';
  5. export interface ShellDeps {
  6. readonly log: ILogger;
  7. }
  8. export interface ShellOptions {
  9. readonly alterPath?: (p: string) => string;
  10. }
  11. export declare class Shell implements IShell {
  12. protected readonly e: ShellDeps;
  13. alterPath: (p: string) => string;
  14. constructor(e: ShellDeps, options?: ShellOptions);
  15. run(command: string, args: readonly string[], { stream, killOnExit, showCommand, showError, fatalOnNotFound, fatalOnError, truncateErrorOutput, ...crossSpawnOptions }: IShellRunOptions): Promise<void>;
  16. output(command: string, args: readonly string[], { fatalOnNotFound, fatalOnError, showError, showCommand, ...crossSpawnOptions }: IShellOutputOptions): Promise<string>;
  17. /**
  18. * When `child_process.spawn` isn't provided a full path to the command
  19. * binary, it behaves differently on Windows than other platforms. For
  20. * Windows, discover the full path to the binary, otherwise fallback to the
  21. * command provided.
  22. *
  23. * @see https://github.com/ionic-team/ionic-cli/issues/3563#issuecomment-425232005
  24. */
  25. resolveCommandPath(command: string, options: SpawnOptions): Promise<string>;
  26. which(command: string, { PATH }?: WhichOptions): Promise<string>;
  27. spawn(command: string, args: readonly string[], { showCommand, ...crossSpawnOptions }: IShellSpawnOptions): Promise<ChildProcess>;
  28. cmdinfo(command: string, args?: readonly string[]): Promise<string | undefined>;
  29. createSubprocess(command: string, args?: readonly string[], options?: SubprocessOptions): Promise<Subprocess>;
  30. protected prepareSpawnOptions(options: IShellSpawnOptions): void;
  31. }
  32. export declare function prependNodeModulesBinToPath(projectDir: string, p: string): string;