-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): replace execa
with tinyexec
#6454
Changes from all commits
c859487
b1870da
ff9679e
fd2b978
c0fd0b1
bc47afe
39c830d
7e01b47
ac65fde
b29436a
2ce84a9
9aebdc4
05e73e2
059cb9c
2e7df2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { resolve } from 'pathe' | ||
import { execa } from 'execa' | ||
import type { ExecaReturnValue } from 'execa' | ||
import type { Output } from 'tinyexec' | ||
import { x } from 'tinyexec' | ||
|
||
export interface GitOptions { | ||
changedSince?: string | boolean | ||
|
@@ -12,10 +12,10 @@ export class VitestGit { | |
constructor(private cwd: string) {} | ||
|
||
private async resolveFilesWithGitCommand(args: string[]): Promise<string[]> { | ||
let result: ExecaReturnValue | ||
let result: Output | ||
|
||
try { | ||
result = await execa('git', args, { cwd: this.root }) | ||
result = await x('git', args, { nodeOptions: { cwd: this.root } }) | ||
} | ||
catch (e: any) { | ||
e.message = e.stderr | ||
|
@@ -75,12 +75,12 @@ export class VitestGit { | |
} | ||
|
||
async getRoot(cwd: string) { | ||
const options = ['rev-parse', '--show-cdup'] | ||
const args = ['rev-parse', '--show-cdup'] | ||
|
||
try { | ||
const result = await execa('git', options, { cwd }) | ||
const result = await x('git', args, { nodeOptions: { cwd } }) | ||
|
||
return resolve(cwd, result.stdout) | ||
return resolve(cwd, result.stdout.trim()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
catch { | ||
return null | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { rm } from 'node:fs/promises' | ||
import { performance } from 'node:perf_hooks' | ||
import type { ExecaChildProcess } from 'execa' | ||
import { execa } from 'execa' | ||
import type { ChildProcess } from 'node:child_process' | ||
import { basename, extname, resolve } from 'pathe' | ||
import { TraceMap, generatedPositionFor } from '@vitest/utils/source-map' | ||
import type { RawSourceMap } from '@ampproject/remapping' | ||
import type { ParsedStack } from '@vitest/utils' | ||
import type { File, Task, TaskResultPack, TaskState } from '@vitest/runner' | ||
import { x } from 'tinyexec' | ||
import { getTasks } from '../utils' | ||
import type { WorkspaceProject } from '../node/workspace' | ||
import type { Awaitable } from '../types/general' | ||
|
@@ -50,7 +50,7 @@ export class Typechecker { | |
private _tests: Record<string, FileInformation> | null = {} | ||
private tempConfigPath?: string | ||
private allowJs?: boolean | ||
private process?: ExecaChildProcess | ||
private process?: ChildProcess | ||
|
||
protected files: string[] = [] | ||
|
||
|
@@ -310,15 +310,17 @@ export class Typechecker { | |
} | ||
this._output = '' | ||
this._startTime = performance.now() | ||
const child = execa(typecheck.checker, args, { | ||
cwd: root, | ||
stdout: 'pipe', | ||
reject: false, | ||
const child = x(typecheck.checker, args, { | ||
nodeOptions: { | ||
cwd: root, | ||
stdio: 'pipe', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
throwOnError: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I've investigated in both |
||
}) | ||
this.process = child | ||
this.process = child.process | ||
await this._onParseStart?.() | ||
let rerunTriggered = false | ||
child.stdout?.on('data', (chunk) => { | ||
child.process?.stdout?.on('data', (chunk) => { | ||
this._output += chunk | ||
if (!watch) { | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tinyexec
doesn't provide a wrapper that passes the options along tostdio
, so we pass them directly.pipe
is used forstdin
(first item in the array) as it was the default inexeca
: https://github.com/sindresorhus/execa/blob/HEAD/docs/api.md#optionsstdin.