diff --git a/src/cmd/init.ts b/src/cmd/init.ts index 42585f1..ec4fe68 100644 --- a/src/cmd/init.ts +++ b/src/cmd/init.ts @@ -99,6 +99,7 @@ async function downloadFromGithub(template: string, standalone?: boolean) { await Deno.mkdir(cacheDir, { recursive: true }); if (!existsSync(`${cacheDir}/${template.split("/").pop()}-${branch}`)) { + await pkgx.installPackage("unzip"); await decompress(filePath, cacheDir); await pkgx.run( `terraform init`, diff --git a/src/pkgx.ts b/src/pkgx.ts index 8260798..7a22654 100644 --- a/src/pkgx.ts +++ b/src/pkgx.ts @@ -42,6 +42,13 @@ export async function run( async function setupPkgx() { await spawn("sh", [ "-c", - "type pkgx > /dev/null || curl -fsS https://pkgx.sh | sh", + "type pkgx > /dev/null 2> /dev/null || curl -fsS https://pkgx.sh | sh", + ]); +} + +export async function installPackage(name: string) { + await spawn("sh", [ + "-c", + `type ${name} > /dev/null 2> /dev/null || pkgx install ${name}`, ]); }