Skip to content

Commit

Permalink
refactor: replace ezsapawn w/ tinyexec
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 22, 2024
1 parent a07d0c2 commit e7ecb2a
Show file tree
Hide file tree
Showing 4 changed files with 15 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.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"
},
Expand Down
11 changes: 8 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 { 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'
Expand Down Expand Up @@ -120,7 +120,7 @@ async function loadGlobalPnpmPackage(options: CheckOptions): Promise<GlobalPacka
let pnpmStdout

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

async function loadGlobalNpmPackage(options: CheckOptions): Promise<GlobalPackageMeta> {
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)

Expand Down Expand Up @@ -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)
}
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 { 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('')
})

0 comments on commit e7ecb2a

Please sign in to comment.