Skip to content

Commit 59cc529

Browse files
pralkarzsheremet-va
authored andcommitted
chore(deps): replace execa with tinyexec (vitest-dev#6454)
Co-authored-by: Vladimir Sheremet <[email protected]>
1 parent 3102a78 commit 59cc529

File tree

14 files changed

+134
-151
lines changed

14 files changed

+134
-151
lines changed

packages/vitest/LICENSE.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,35 +1586,6 @@ Repository: git+https://github.com/antfu/strip-literal.git
15861586
15871587
---------------------------------------
15881588

1589-
## tinyexec
1590-
License: MIT
1591-
By: James Garbutt
1592-
Repository: git+https://github.com/tinylibs/tinyexec.git
1593-
1594-
> MIT License
1595-
>
1596-
> Copyright (c) 2024 Tinylibs
1597-
>
1598-
> Permission is hereby granted, free of charge, to any person obtaining a copy
1599-
> of this software and associated documentation files (the "Software"), to deal
1600-
> in the Software without restriction, including without limitation the rights
1601-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1602-
> copies of the Software, and to permit persons to whom the Software is
1603-
> furnished to do so, subject to the following conditions:
1604-
>
1605-
> The above copyright notice and this permission notice shall be included in all
1606-
> copies or substantial portions of the Software.
1607-
>
1608-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1609-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1610-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1611-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1612-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1613-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1614-
> SOFTWARE.
1615-
1616-
---------------------------------------
1617-
16181589
## to-regex-range
16191590
License: MIT
16201591
By: Jon Schlinkert, Rouven Weßling

packages/vitest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@
159159
"@vitest/utils": "workspace:*",
160160
"chai": "^5.1.1",
161161
"debug": "^4.3.6",
162-
"execa": "^8.0.1",
163162
"magic-string": "^0.30.11",
164163
"pathe": "^1.1.2",
165164
"std-env": "^3.7.0",
166165
"tinybench": "^2.9.0",
166+
"tinyexec": "^0.3.0",
167167
"tinypool": "^1.0.0",
168168
"tinyrainbow": "^1.2.0",
169169
"vite": "^5.0.0",

packages/vitest/src/create/browser/creator.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import c from 'tinyrainbow'
66
import type { Agent } from '@antfu/install-pkg'
77
import { detectPackageManager, installPackage } from '@antfu/install-pkg'
88
import { findUp } from 'find-up'
9-
import { execa } from 'execa'
9+
import { x } from 'tinyexec'
1010
import type { BrowserBuiltinProvider } from '../../node/types/browser'
1111
import { configFiles } from '../../constants'
1212
import { generateExampleFiles } from './examples'
@@ -499,9 +499,10 @@ export async function create() {
499499
const allArgs = [...args, 'playwright', 'install', '--with-deps']
500500
log(c.cyan('◼'), `Installing Playwright dependencies with \`${c.bold(command)} ${c.bold(allArgs.join(' '))}\`...`)
501501
log()
502-
await execa(command, allArgs, {
503-
stdout: 'inherit',
504-
stderr: 'inherit',
502+
await x(command, allArgs, {
503+
nodeOptions: {
504+
stdio: ['pipe', 'inherit', 'inherit'],
505+
},
505506
})
506507
}
507508

packages/vitest/src/node/git.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { resolve } from 'pathe'
2-
import { execa } from 'execa'
3-
import type { ExecaReturnValue } from 'execa'
2+
import type { Output } from 'tinyexec'
3+
import { x } from 'tinyexec'
44

55
export interface GitOptions {
66
changedSince?: string | boolean
@@ -12,10 +12,10 @@ export class VitestGit {
1212
constructor(private cwd: string) {}
1313

1414
private async resolveFilesWithGitCommand(args: string[]): Promise<string[]> {
15-
let result: ExecaReturnValue
15+
let result: Output
1616

1717
try {
18-
result = await execa('git', args, { cwd: this.root })
18+
result = await x('git', args, { nodeOptions: { cwd: this.root } })
1919
}
2020
catch (e: any) {
2121
e.message = e.stderr
@@ -75,12 +75,12 @@ export class VitestGit {
7575
}
7676

7777
async getRoot(cwd: string) {
78-
const options = ['rev-parse', '--show-cdup']
78+
const args = ['rev-parse', '--show-cdup']
7979

8080
try {
81-
const result = await execa('git', options, { cwd })
81+
const result = await x('git', args, { nodeOptions: { cwd } })
8282

83-
return resolve(cwd, result.stdout)
83+
return resolve(cwd, result.stdout.trim())
8484
}
8585
catch {
8686
return null

packages/vitest/src/typecheck/typechecker.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { rm } from 'node:fs/promises'
22
import { performance } from 'node:perf_hooks'
3-
import type { ExecaChildProcess } from 'execa'
4-
import { execa } from 'execa'
3+
import type { ChildProcess } from 'node:child_process'
54
import { basename, extname, resolve } from 'pathe'
65
import { TraceMap, generatedPositionFor } from '@vitest/utils/source-map'
76
import type { RawSourceMap } from '@ampproject/remapping'
87
import type { ParsedStack } from '@vitest/utils'
98
import type { File, Task, TaskResultPack, TaskState } from '@vitest/runner'
9+
import { x } from 'tinyexec'
1010
import { getTasks } from '../utils'
1111
import type { WorkspaceProject } from '../node/workspace'
1212
import type { Awaitable } from '../types/general'
@@ -50,7 +50,7 @@ export class Typechecker {
5050
private _tests: Record<string, FileInformation> | null = {}
5151
private tempConfigPath?: string
5252
private allowJs?: boolean
53-
private process?: ExecaChildProcess
53+
private process?: ChildProcess
5454

5555
protected files: string[] = []
5656

@@ -310,15 +310,17 @@ export class Typechecker {
310310
}
311311
this._output = ''
312312
this._startTime = performance.now()
313-
const child = execa(typecheck.checker, args, {
314-
cwd: root,
315-
stdout: 'pipe',
316-
reject: false,
313+
const child = x(typecheck.checker, args, {
314+
nodeOptions: {
315+
cwd: root,
316+
stdio: 'pipe',
317+
},
318+
throwOnError: false,
317319
})
318-
this.process = child
320+
this.process = child.process
319321
await this._onParseStart?.()
320322
let rerunTriggered = false
321-
child.stdout?.on('data', (chunk) => {
323+
child.process?.stdout?.on('data', (chunk) => {
322324
this._output += chunk
323325
if (!watch) {
324326
return

0 commit comments

Comments
 (0)