From bb6db3f68a9611d83f9cdc2380369b6d7e9a526e Mon Sep 17 00:00:00 2001 From: Horu <73709188+HigherOrderLogic@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:59:40 +1100 Subject: [PATCH] fix(typecheck): use `bunx` if running on bun (#494) --- src/commands/typecheck.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/commands/typecheck.ts b/src/commands/typecheck.ts index 7df03325..73e4848f 100644 --- a/src/commands/typecheck.ts +++ b/src/commands/typecheck.ts @@ -1,6 +1,7 @@ import { execa } from 'execa' import { resolve } from 'pathe' import { defineCommand } from 'citty' +import { isBun } from 'std-env' // we are deliberately inlining this code as a backup in case user has `@nuxt/schema<3.7` import { writeTypes as writeTypesLegacy } from '@nuxt/kit' @@ -55,11 +56,25 @@ export default defineCommand({ }) } else { - await execa( - 'npx', - '-p vue-tsc -p typescript vue-tsc --noEmit'.split(' '), - { stdio: 'inherit', cwd }, - ) + if (isBun) { + await execa( + 'bun', + 'install typescript vue-tsc --global --silent'.split(' '), + { stdio: 'inherit', cwd }, + ) + + await execa('bunx', 'vue-tsc --noEmit'.split(' '), { + stdio: 'inherit', + cwd, + }) + } + else { + await execa( + 'npx', + '-p vue-tsc -p typescript vue-tsc --noEmit'.split(' '), + { stdio: 'inherit', cwd }, + ) + } } }, })