1- import { makeRunCommand } from "./utils" ;
1+ import { HardhatPluginError } from "hardhat/plugins" ;
2+ import { makeRunCommand , PLUGIN_NAME } from "./utils" ;
23
34const installationSeparator = "hardhat" ;
45
@@ -9,9 +10,10 @@ async function installNoirup() {
910 if ( ! fs . existsSync ( noirupBinary ) ) {
1011 const runCommand = makeRunCommand ( ) ;
1112 console . log ( "Installing noirup" ) ;
12- await runCommand (
13- "curl -L https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install | bash " ,
13+ const installScript = await downloadScript (
14+ "https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install" ,
1415 ) ;
16+ await runCommand ( "bash" , [ "-c" , installScript ] ) ;
1517 }
1618 return noirupBinary ;
1719}
@@ -33,9 +35,9 @@ export async function installNargo(version: string) {
3335 const nargoBinDir = path . dirname ( nargoBinary ) ;
3436 fs . mkdirSync ( path . join ( nargoBinDir ) , { recursive : true } ) ;
3537 console . log ( `Installing nargo@${ version } in ${ nargoBinDir } ` ) ;
36- await runCommand (
37- `NARGO_HOME= ${ path . dirname ( nargoBinDir ) } ${ noirupBinary } -v ${ version } ` ,
38- ) ;
38+ await runCommand ( noirupBinary , [ "-v" , version ] , {
39+ env : { NARGO_HOME : path . dirname ( nargoBinDir ) } ,
40+ } ) ;
3941 }
4042 return nargoBinary ;
4143}
@@ -45,3 +47,11 @@ async function getNargoHome() {
4547 const path = await import ( "path" ) ;
4648 return path . join ( os . homedir ( ) , ".nargo" ) ;
4749}
50+
51+ async function downloadScript ( url : string ) {
52+ const res = await fetch ( url ) ;
53+ if ( ! res . ok ) {
54+ throw new HardhatPluginError ( PLUGIN_NAME , `Failed to download ${ url } ` ) ;
55+ }
56+ return await res . text ( ) ;
57+ }
0 commit comments