UNPKG

@teambit/isolator

Version:
78 lines (77 loc) 2.62 kB
import type { NodeFS } from '@teambit/any-fs'; import type { Exec } from '@teambit/capsule'; import { Capsule as CapsuleTemplate, Console, State } from '@teambit/capsule'; import type { Component } from '@teambit/component'; import type { BitExecOption } from './container'; import FsContainer from './container'; import ContainerExec from './container-exec'; export default class Capsule extends CapsuleTemplate<Exec, NodeFS> { /** * container implementation the capsule is being executed within. */ protected container: FsContainer; /** * the capsule's file system. */ readonly fs: NodeFS; /** * console for controlling process streams as stdout, stdin and stderr. */ readonly console: Console; /** * capsule's state. */ readonly state: State; readonly component: Component; private _wrkDir; constructor( /** * container implementation the capsule is being executed within. */ container: FsContainer, /** * the capsule's file system. */ fs: NodeFS, /** * console for controlling process streams as stdout, stdin and stderr. */ console: Console | undefined, /** * capsule's state. */ state: State, component: Component); /** * @deprecated please use `this.path` */ get wrkDir(): string; get path(): string; start(): Promise<any>; execNode(executable: string, args: any, exec: ContainerExec): Promise<ContainerExec>; typedExec(opts: BitExecOption, exec?: ContainerExec): Promise<ContainerExec>; outputFile(file: string, data: any, options?: any): Promise<any>; removePath(dir: string): Promise<any>; symlink(src: string, dest: string): Promise<any>; execute(cmd: string, options?: Record<string, any> | null | undefined): Promise<unknown>; /** * @todo: fix. * it skips the capsule fs because for some reason `capsule.fs.promises.readdir` doesn't work * the same as `capsule.fs.readdir` and it doesn't have the capsule dir as pwd. * * returns the paths inside the capsule */ getAllFilesPaths(dir?: string, options?: { ignore?: string[]; }): any; static getCapsuleDirName(component: Component, config?: { alwaysNew?: boolean; name?: string; }): string; static getCapsuleRootDir(component: Component, baseDir: string, config?: { alwaysNew?: boolean; name?: string; }): string; static createFromComponent(component: Component, baseDir: string, config?: { alwaysNew?: boolean; }): Promise<Capsule>; }