Skip to content

Commit 6451708

Browse files
chore: use "child_process" insetad of "execa"
1 parent 7666b69 commit 6451708

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

utils.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from 'path'
22
import fs from 'fs'
33
import { fileURLToPath } from 'url'
4-
import { execaCommand } from 'execa'
54
import type {
65
EnvironmentData,
76
Overrides,
@@ -15,6 +14,7 @@ import { detect, AGENTS, Agent, getCommand } from '@antfu/ni'
1514
import actionsCore from '@actions/core'
1615
// eslint-disable-next-line n/no-unpublished-import
1716
import * as semver from 'semver'
17+
import { execSync } from 'child_process'
1818

1919
const isGitHubActions = !!process.env.GITHUB_ACTIONS
2020

@@ -26,7 +26,10 @@ function cd(dir: string) {
2626
cwd = path.resolve(cwd, dir)
2727
}
2828

29-
export async function $(literals: TemplateStringsArray, ...values: any[]) {
29+
export async function $(
30+
literals: TemplateStringsArray,
31+
...values: any[]
32+
): Promise<string> {
3033
const cmd = literals.reduce(
3134
(result, current, i) =>
3235
result + current + (values?.[i] != null ? `${values[i]}` : ''),
@@ -39,32 +42,16 @@ export async function $(literals: TemplateStringsArray, ...values: any[]) {
3942
console.log(`${cwd} $> ${cmd}`)
4043
}
4144

42-
const proc = execaCommand(cmd, {
43-
env,
44-
stdio: 'pipe',
45+
const result = execSync(cmd, {
4546
cwd,
47+
encoding: 'utf-8',
4648
})
47-
proc.stdin && process.stdin.pipe(proc.stdin)
48-
proc.stdout && proc.stdout.pipe(process.stdout)
49-
proc.stderr && proc.stderr.pipe(process.stderr)
50-
51-
let result
52-
try {
53-
result = await proc
54-
} catch (error) {
55-
// Since we already piped the io to the parent process, we remove the duplicated
56-
// messages here so it's easier to read the error message.
57-
if (error.stdout) error.stdout = 'value removed by vite-ecosystem-ci'
58-
if (error.stderr) error.stderr = 'value removed by vite-ecosystem-ci'
59-
if (error.stdio) error.stdio = ['value removed by vite-ecosystem-ci']
60-
throw error
61-
}
6249

6350
if (isGitHubActions) {
6451
actionsCore.endGroup()
6552
}
6653

67-
return result.stdout
54+
return result
6855
}
6956

7057
export async function setupEnvironment(): Promise<EnvironmentData> {
@@ -75,7 +62,6 @@ export async function setupEnvironment(): Promise<EnvironmentData> {
7562
env = {
7663
...process.env,
7764
CI: 'true',
78-
TURBO_FORCE: 'true', // disable turbo caching, ecosystem-ci modifies things and we don't want replays
7965
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false', // to avoid errors with mutated lockfile due to overrides
8066
NODE_OPTIONS: '--max-old-space-size=6144', // GITHUB CI has 7GB max, stay below
8167
ECOSYSTEM_CI: 'true', // flag for tests, can be used to conditionally skip irrelevant tests.

0 commit comments

Comments
 (0)