From e7ecb2af700a9c6d65b044273647933274f91eec Mon Sep 17 00:00:00 2001 From: SukkaW Date: Thu, 22 Aug 2024 11:31:12 +0800 Subject: [PATCH] refactor: replace `ezsapawn` w/ `tinyexec` --- package.json | 2 +- pnpm-lock.yaml | 11 ++++++++--- src/commands/check/checkGlobal.ts | 8 ++++---- test/cli.test.ts | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 055d036..c434bbb 100644 --- a/package.json +++ b/package.json @@ -35,10 +35,10 @@ }, "dependencies": { "@antfu/ni": "^0.22.1", - "@jsdevtools/ez-spawn": "^3.0.4", "js-yaml": "^4.1.0", "npm-registry-fetch": "^17.1.0", "ofetch": "^1.3.4", + "tinyexec": "^0.2.0", "unconfig": "^0.5.5", "yargs": "^17.7.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9c39fc..2c416ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: '@antfu/ni': specifier: ^0.22.1 version: 0.22.1 - '@jsdevtools/ez-spawn': - specifier: ^3.0.4 - version: 3.0.4 js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -23,6 +20,9 @@ importers: ofetch: specifier: ^1.3.4 version: 1.3.4 + tinyexec: + specifier: ^0.2.0 + version: 0.2.0 unconfig: specifier: ^0.5.5 version: 0.5.5 @@ -2907,6 +2907,9 @@ packages: tinybench@2.8.0: resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} + tinyexec@0.2.0: + resolution: {integrity: sha512-au8dwv4xKSDR+Fw52csDo3wcDztPdne2oM1o/7LFro4h6bdFmvyUAeAfX40pwDtzHgRFqz1XWaUqgKS2G83/ig==} + tinypool@1.0.0: resolution: {integrity: sha512-KIKExllK7jp3uvrNtvRBYBWBOAXSX8ZvoaD8T+7KB/QHIuoJW3Pmr60zucywjAlMb5TeXUkcs/MWeWLu0qvuAQ==} engines: {node: ^18.0.0 || >=20.0.0} @@ -6060,6 +6063,8 @@ snapshots: tinybench@2.8.0: {} + tinyexec@0.2.0: {} + tinypool@1.0.0: {} tinyrainbow@1.2.0: {} diff --git a/src/commands/check/checkGlobal.ts b/src/commands/check/checkGlobal.ts index 1bebe81..9485cb7 100644 --- a/src/commands/check/checkGlobal.ts +++ b/src/commands/check/checkGlobal.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { async as ezspawn } from '@jsdevtools/ez-spawn' +import { exec } from 'tinyexec' import c from 'picocolors' import prompts from 'prompts' import { type Agent, getCommand } from '@antfu/ni' @@ -120,7 +120,7 @@ async function loadGlobalPnpmPackage(options: CheckOptions): Promise { - const { stdout } = await ezspawn('npm', ['ls', '--global', '--depth=0', '--json'], { stdio: 'pipe' }) + const { stdout } = await exec('npm', ['ls', '--global', '--depth=0', '--json']) const npmOut = JSON.parse(stdout) as NpmOut const filter = createDependenciesFilter(options.include, options.exclude) @@ -188,5 +188,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 ezspawn(installCommand, { stdio: 'inherit' }) + await exec(installCommand) } diff --git a/test/cli.test.ts b/test/cli.test.ts index c0e476d..988e838 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 { async as ezspawn } from '@jsdevtools/ez-spawn' +import { exec } from 'tinyexec' it('taze cli should just works', async () => { const binPath = path.resolve(__dirname, '../bin/taze.mjs') - const proc = await ezspawn(process.execPath, [binPath], { stdio: 'pipe' }) + const proc = await exec(process.execPath, [binPath]) expect(proc.stderr).toBe('') })