Skip to content

Commit

Permalink
Merge pull request #6 from pocketenv-io/fix/install-unzip
Browse files Browse the repository at this point in the history
fix(init): install `unzip` if not installed
  • Loading branch information
tsirysndr authored Aug 18, 2024
2 parents ac9a71f + 9f04089 commit 65b0326
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cmd/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
9 changes: 8 additions & 1 deletion src/pkgx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
]);
}

0 comments on commit 65b0326

Please sign in to comment.