(
shell: Pick<
Shell,
"binaryName" | "launchArgs" | "currentlySupported" | "forceFile"
>
)
| 38 | } |
| 39 | |
| 40 | async execute( |
| 41 | shell: Pick< |
| 42 | Shell, |
| 43 | "binaryName" | "launchArgs" | "currentlySupported" | "forceFile" |
| 44 | > |
| 45 | ): Promise<void> { |
| 46 | if (!shell.currentlySupported()) { |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | const args = [...shell.launchArgs()] |
| 51 | |
| 52 | if (shell.forceFile) { |
| 53 | let filename = join(testTmpDir(), "script") |
| 54 | if (typeof shell.forceFile === "string") { |
| 55 | filename = filename + shell.forceFile |
| 56 | } |
| 57 | await writeFile(filename, [...this.lines, "exit 0"].join("\n")) |
| 58 | args.push(filename) |
| 59 | } |
| 60 | |
| 61 | const child = execa(shell.binaryName(), args, { |
| 62 | stdio: [shell.forceFile ? "ignore" : "pipe", "pipe", "pipe"], |
| 63 | cwd: testCwd(), |
| 64 | env: (() => { |
| 65 | const newProcessEnv: Record<string, string> = { |
| 66 | ...this.extraEnvVars, |
| 67 | ...removeAllFnmEnvVars(process.env), |
| 68 | PATH: [testBinDir(), fnmTargetDir(), process.env.PATH] |
| 69 | .filter(Boolean) |
| 70 | .join(path.delimiter), |
| 71 | FNM_DIR: this.config.fnmDir, |
| 72 | FNM_NODE_DIST_MIRROR: "http://localhost:8080", |
| 73 | } |
| 74 | |
| 75 | delete newProcessEnv.NODE_OPTIONS |
| 76 | return newProcessEnv |
| 77 | })(), |
| 78 | extendEnv: false, |
| 79 | reject: false, |
| 80 | }) |
| 81 | |
| 82 | if (child.stdin) { |
| 83 | const childStdin = child.stdin |
| 84 | |
| 85 | for (const line of this.lines) { |
| 86 | await write(childStdin, `${line}\n`) |
| 87 | } |
| 88 | |
| 89 | await write(childStdin, "exit 0\n") |
| 90 | } |
| 91 | |
| 92 | const { stdout, stderr } = streamOutputsAndBuffer(child) |
| 93 | |
| 94 | const finished = await child |
| 95 | |
| 96 | if (finished.failed) { |
| 97 | console.error( |
no test coverage detected