@@ -73,11 +73,6 @@ async function parsePackageJson() {
7373 url = url . replace ( / { { version} } / g, version ) ;
7474 url = url . replace ( / { { bin_ n a m e } } / g, binName ) ;
7575
76- // Binary name on Windows has .exe suffix
77- if ( process . platform === "win32" ) {
78- binName += ".exe" ;
79- }
80-
8176 return { binName, binPath, url, version } ;
8277}
8378
@@ -93,10 +88,11 @@ async function main() {
9388 const opts = await parsePackageJson ( ) ;
9489 await fs . promises . mkdir ( opts . binPath , { recursive : true } ) ;
9590
96- // First we will Un-GZip, then we will untar. So once untar is completed,
97- // binary is downloaded into `downloadPath`. Verify the binary and call it good
91+ // First we will Un-GZip, then we will untar.
9892 const ungz = zlib . createGunzip ( ) ;
99- const untar = tar . x ( { cwd : opts . binPath } , [ opts . binName ] ) ;
93+ // Binary name on Windows has .exe suffix
94+ const ext = process . platform === "win32" ? ".exe" : "" ;
95+ const untar = tar . x ( { cwd : opts . binPath } , [ opts . binName + ext ] ) ;
10096
10197 console . info ( "Downloading" , opts . url ) ;
10298 const resp = await fetch ( opts . url ) ;
@@ -106,6 +102,12 @@ async function main() {
106102 untar . on ( "end" , ( ) => resolve ( ) ) ;
107103 } ) ;
108104
105+ // Creates a hardlink for npm to find the binary on Windows
106+ if ( ext ) {
107+ const bin = path . join ( opts . binPath , opts . binName ) ;
108+ await fs . promises . link ( bin + ext , bin ) ;
109+ }
110+
109111 // TODO: verify checksums
110112 console . info ( "Installed Supabase CLI successfully" ) ;
111113}
0 commit comments