| 14 | } |
| 15 | |
| 16 | export async function runWingCommand(options: RunWingCommandOptions) { |
| 17 | const platformOptions: string[] = []; |
| 18 | options.platforms?.forEach((p) => platformOptions.push(...["-t", `${p}`])) ?? |
| 19 | []; |
| 20 | const out = await execa( |
| 21 | wingBin, |
| 22 | [ |
| 23 | "--no-update-check", |
| 24 | "--no-analytics", |
| 25 | ...options.args, |
| 26 | options.wingFile ?? "", |
| 27 | ...platformOptions, |
| 28 | ], |
| 29 | { |
| 30 | cwd: options.cwd, |
| 31 | reject: false, |
| 32 | stdin: "ignore", |
| 33 | env: options.env, |
| 34 | } |
| 35 | ); |
| 36 | |
| 37 | const output = [out.stdout, out.stderr].join("\n"); |
| 38 | |
| 39 | if (options.expectFailure) { |
| 40 | if (out.exitCode == 0) { |
| 41 | expect.fail(output); |
| 42 | } |
| 43 | } else { |
| 44 | if (out.exitCode != 0) { |
| 45 | expect.fail(output); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return { |
| 50 | stderr: sanitizeOutput(out.stderr), |
| 51 | stdout: sanitizeOutput(out.stdout), |
| 52 | }; |
| 53 | } |
| 54 | |
| 55 | export function sanitizeOutput(output: string) { |
| 56 | return ( |