Skip to content

Commit

Permalink
refactor: replace execa w/ ezspawn
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Apr 25, 2024
1 parent eb4201b commit bf603c5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
},
"dependencies": {
"@antfu/ni": "^0.21.12",
"@jsdevtools/ez-spawn": "^3.0.4",
"cli-progress": "^3.12.0",
"deepmerge": "^4.3.1",
"detect-indent": "^7.0.1",
"execa": "^8.0.1",
"picocolors": "^1.0.0",
"prompts": "^2.4.2",
"ufo": "^1.5.3",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/commands/check/checkGlobal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { execa, execaCommand } from 'execa'
import { async as ezspawnAsync } from '@jsdevtools/ez-spawn'
import c from 'picocolors'
import prompts from 'prompts'
import { type Agent, getCommand } from '@antfu/ni'
Expand Down Expand Up @@ -118,7 +118,7 @@ async function loadGlobalPnpmPackage(options: CheckOptions): Promise<GlobalPacka
let pnpmStdout

try {
pnpmStdout = (await execa('pnpm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' })).stdout
pnpmStdout = (await ezspawnAsync('pnpm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' })).stdout
}
catch (error) {
return []
Expand Down Expand Up @@ -152,7 +152,7 @@ async function loadGlobalPnpmPackage(options: CheckOptions): Promise<GlobalPacka
}

async function loadGlobalNpmPackage(options: CheckOptions): Promise<GlobalPackageMeta> {
const { stdout } = await execa('npm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' })
const { stdout } = await ezspawnAsync('npm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' })
const npmOut = JSON.parse(stdout) as NpmOut
const filter = createDependenciesFilter(options.include, options.exclude)

Expand Down Expand Up @@ -182,5 +182,5 @@ async function installPkg(pkg: GlobalPackageMeta) {
const dependencies = dumpDependencies(changes, 'dependencies')
const updateArgs = Object.entries(dependencies).map(([name, version]) => `${name}@${version}`)
const installCommand = getCommand(pkg.agent, 'global', [...updateArgs])
await execaCommand(installCommand, { stdio: 'inherit' })
await ezspawnAsync(installCommand, { stdio: 'inherit' })
}
4 changes: 2 additions & 2 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'node:path'
import { expect, it } from 'vitest'
import { execa } from 'execa'
import { async as ezspawnAsync } from '@jsdevtools/ez-spawn'

it('taze cli should just works', async () => {
const binPath = path.resolve(__dirname, '../bin/taze.mjs')

const proc = await execa(process.execPath, [binPath], { stdio: 'pipe' })
const proc = await ezspawnAsync(process.execPath, [binPath], { stdio: 'pipe' })

expect(proc.stderr).toBe('')
})

0 comments on commit bf603c5

Please sign in to comment.