From 5c7aa67c3681ec9e9a04c56368258431493088a5 Mon Sep 17 00:00:00 2001 From: Sukka Date: Fri, 26 Apr 2024 01:50:56 +0800 Subject: [PATCH] refactor: replace `execa` w/ `ezspawn` (#115) --- package.json | 2 +- pnpm-lock.yaml | 6 +++--- src/commands/check/checkGlobal.ts | 8 ++++---- test/cli.test.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index b77a869..8371214 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4749b6a..ff91b22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@antfu/ni': specifier: ^0.21.12 version: 0.21.12 + '@jsdevtools/ez-spawn': + specifier: ^3.0.4 + version: 3.0.4 cli-progress: specifier: ^3.12.0 version: 3.12.0 @@ -20,9 +23,6 @@ importers: detect-indent: specifier: ^7.0.1 version: 7.0.1 - execa: - specifier: ^8.0.1 - version: 8.0.1 picocolors: specifier: ^1.0.0 version: 1.0.0 diff --git a/src/commands/check/checkGlobal.ts b/src/commands/check/checkGlobal.ts index 6b6c59c..dd4a21d 100644 --- a/src/commands/check/checkGlobal.ts +++ b/src/commands/check/checkGlobal.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { execa, execaCommand } from 'execa' +import { async as ezspawn } from '@jsdevtools/ez-spawn' import c from 'picocolors' import prompts from 'prompts' import { type Agent, getCommand } from '@antfu/ni' @@ -118,7 +118,7 @@ async function loadGlobalPnpmPackage(options: CheckOptions): Promise { - const { stdout } = await execa('npm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' }) + const { stdout } = await ezspawn('npm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' }) const npmOut = JSON.parse(stdout) as NpmOut const filter = createDependenciesFilter(options.include, options.exclude) @@ -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 ezspawn(installCommand, { stdio: 'inherit' }) } diff --git a/test/cli.test.ts b/test/cli.test.ts index 79c60dc..c0e476d 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -1,11 +1,11 @@ import path from 'node:path' import { expect, it } from 'vitest' -import { execa } from 'execa' +import { async as ezspawn } 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 ezspawn(process.execPath, [binPath], { stdio: 'pipe' }) expect(proc.stderr).toBe('') })