Skip to content

Commit

Permalink
refactor(dependencies): use execa instead of child_process
Browse files Browse the repository at this point in the history
  • Loading branch information
6km committed May 27, 2024
1 parent 1aae5dd commit 4c920ce
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/hooks/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { chdir, exit } from 'process'
import confirm from '@inquirer/confirm'
import select from '@inquirer/select'
import chalk from 'chalk'
import { execa } from 'execa'
import { createSpinner } from 'nanospinner'
import { projectDependenciesHook } from '../hook'

Expand Down Expand Up @@ -102,13 +103,9 @@ function getCurrentPackageManager(): PackageManager {

function checkPackageManagerInstalled(packageManager: string) {
return new Promise<boolean>((resolve) => {
exec(`${packageManager} --version`, (error) => {
if (error) {
resolve(false)
} else {
resolve(true)
}
})
execa(packageManager, ['--version'])
.then(() => resolve(true))
.catch(() => resolve(false))
})
}

Expand Down

0 comments on commit 4c920ce

Please sign in to comment.