11import { mkdtemp , rm , writeFile } from "node:fs/promises" ;
22import { tmpdir } from "node:os" ;
33import path from "node:path" ;
4- import { pathToFileURL } from "node:url" ;
54
65import { describe , expect , it } from "vitest" ;
76
8- import { resolveViteBin } from "./tsed-build.js" ;
7+ import { resolveViteBinFromPackageJsonPath } from "./tsed-build.js" ;
98
109async function withTempDir ( run : ( cwd : string ) => Promise < void > ) {
1110 const cwd = await mkdtemp ( path . join ( tmpdir ( ) , "tsed-build-" ) ) ;
@@ -23,7 +22,7 @@ describe("tsed-build", () => {
2322 const packageJsonPath = path . join ( cwd , "package.json" ) ;
2423 await writeFile ( packageJsonPath , JSON . stringify ( { bin : { vite : "bin/vite.js" } } ) ) ;
2524
26- const viteBin = await resolveViteBin ( async ( ) => pathToFileURL ( packageJsonPath ) . href ) ;
25+ const viteBin = await resolveViteBinFromPackageJsonPath ( packageJsonPath ) ;
2726
2827 expect ( viteBin ) . toEqual ( path . join ( cwd , "bin/vite.js" ) ) ;
2928 } ) ;
@@ -34,7 +33,7 @@ describe("tsed-build", () => {
3433 const packageJsonPath = path . join ( cwd , "package.json" ) ;
3534 await writeFile ( packageJsonPath , JSON . stringify ( { bin : "bin/vite.js" } ) ) ;
3635
37- const viteBin = await resolveViteBin ( async ( ) => pathToFileURL ( packageJsonPath ) . href ) ;
36+ const viteBin = await resolveViteBinFromPackageJsonPath ( packageJsonPath ) ;
3837
3938 expect ( viteBin ) . toEqual ( path . join ( cwd , "bin/vite.js" ) ) ;
4039 } ) ;
@@ -45,7 +44,7 @@ describe("tsed-build", () => {
4544 const packageJsonPath = path . join ( cwd , "package.json" ) ;
4645 await writeFile ( packageJsonPath , JSON . stringify ( { name : "vite" } ) ) ;
4746
48- await expect ( resolveViteBin ( async ( ) => pathToFileURL ( packageJsonPath ) . href ) ) . rejects . toThrowError (
47+ await expect ( resolveViteBinFromPackageJsonPath ( packageJsonPath ) ) . rejects . toThrowError (
4948 "Unable to resolve Vite CLI binary from vite/package.json"
5049 ) ;
5150 } ) ;
0 commit comments