Skip to content

Commit

Permalink
chore(deps): replace execa with tinyexec (#6454)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir Sheremet <[email protected]>
  • Loading branch information
ziebam and sheremet-va authored Sep 6, 2024
1 parent b992b34 commit 0282564
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 151 deletions.
29 changes: 0 additions & 29 deletions packages/vitest/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1586,35 +1586,6 @@ Repository: git+https://github.com/antfu/strip-literal.git
---------------------------------------

## tinyexec
License: MIT
By: James Garbutt
Repository: git+https://github.com/tinylibs/tinyexec.git

> MIT License
>
> Copyright (c) 2024 Tinylibs
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
---------------------------------------

## to-regex-range
License: MIT
By: Jon Schlinkert, Rouven Weßling
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@
"@vitest/utils": "workspace:*",
"chai": "^5.1.1",
"debug": "^4.3.6",
"execa": "^8.0.1",
"magic-string": "^0.30.11",
"pathe": "^1.1.2",
"std-env": "^3.7.0",
"tinybench": "^2.9.0",
"tinyexec": "^0.3.0",
"tinypool": "^1.0.0",
"tinyrainbow": "^1.2.0",
"vite": "^5.0.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/vitest/src/create/browser/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import c from 'tinyrainbow'
import type { Agent } from '@antfu/install-pkg'
import { detectPackageManager, installPackage } from '@antfu/install-pkg'
import { findUp } from 'find-up'
import { execa } from 'execa'
import { x } from 'tinyexec'
import type { BrowserBuiltinProvider } from '../../node/types/browser'
import { configFiles } from '../../constants'
import { generateExampleFiles } from './examples'
Expand Down Expand Up @@ -499,9 +499,10 @@ export async function create() {
const allArgs = [...args, 'playwright', 'install', '--with-deps']
log(c.cyan('◼'), `Installing Playwright dependencies with \`${c.bold(command)} ${c.bold(allArgs.join(' '))}\`...`)
log()
await execa(command, allArgs, {
stdout: 'inherit',
stderr: 'inherit',
await x(command, allArgs, {
nodeOptions: {
stdio: ['pipe', 'inherit', 'inherit'],
},
})
}

Expand Down
14 changes: 7 additions & 7 deletions packages/vitest/src/node/git.ts
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
Expand All @@ -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
Expand Down Expand Up @@ -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())
}
catch {
return null
Expand Down
20 changes: 11 additions & 9 deletions packages/vitest/src/typecheck/typechecker.ts
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'
Expand Down Expand Up @@ -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[] = []

Expand Down Expand Up @@ -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',
},
throwOnError: false,
})
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
Expand Down
Loading

0 comments on commit 0282564

Please sign in to comment.