Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ShellContext

Hierarchy

Index

Properties

Protected _logger

_logger: Logger = logger

logCommand

logCommand: boolean = false

sleep

sleep: sleep = sleep

Accessors

cwd

  • get cwd(): string

Methods

cd

  • cd(dir: string): this
  • change work directory

    Parameters

    • dir: string

    Returns this

env

  • env(key: string): string | undefined
  • env(key: string, val: string | undefined): this
  • set/get/delete env set: ctx.env('key', 'val') get: ctx.env('key') delete: ctx.env('key', void 0)

    Parameters

    • key: string

    Returns string | undefined

  • Parameters

    • key: string
    • val: string | undefined

    Returns this

exec

  • exec(command: string, options?: execa.Options): execa.ExecaChildProcess
  • exec(commands: string[], options?: execa.Options): Promise<ExecaSyncReturnValue[]>
  • execute command(s)

    Parameters

    • command: string
    • Optional options: execa.Options

    Returns execa.ExecaChildProcess

  • Parameters

    • commands: string[]
    • Optional options: execa.Options

    Returns Promise<ExecaSyncReturnValue[]>

exec_unix

  • exec_unix(cmd: string, options?: execa.Options): ExecaChildProcess<string>
  • exec (multi-line) cmd in *unix platforms, via this.spawn('$SHELL', ['-i','-c', cmd])

    Parameters

    • cmd: string
    • Optional options: execa.Options

    Returns ExecaChildProcess<string>

monitor

  • monitor(dir: string, run: ((p: { current: ChildProcess | null }) => void) | string | string[], options?: WatchDirOptions & { ignore?: undefined | ((event: string, file: string) => boolean) }): void
  • restart processes when file changes

    example

    ctx.monitor('./src', 'tsc') ctx.monitor('./src', 'webpack') ctx.monitor('./src', 'foy watch') ctx.monitor('./src', ['rm -rf dist', 'foy watch']) ctx.monitor('./src', async p => { await fs.rmrf('dist') p.current = ctx.exec('webpack serve') })

    Parameters

    • dir: string
    • run: ((p: { current: ChildProcess | null }) => void) | string | string[]
    • Default value options: WatchDirOptions & { ignore?: undefined | ((event: string, file: string) => boolean) } = {}

    Returns void

popd

  • popd(): this

pushd

  • pushd(dir: string): this
  • like pushd in shell

    Parameters

    • dir: string

    Returns this

resetEnv

  • resetEnv(): this

spawn

  • spawn(file: string, args?: string[], options?: execa.Options): execa.ExecaChildProcess
  • spawn file

    Parameters

    • file: string
    • Default value args: string[] = []
    • Optional options: execa.Options

    Returns execa.ExecaChildProcess

Generated using TypeDoc