From 499d83c9befd24749bbf790c789ede248c36ba54 Mon Sep 17 00:00:00 2001 From: Assistant <12+assistant@git@zakscode.com> Date: Thu, 17 Sep 2026 01:28:37 -0400 Subject: [PATCH] Fix install-kwix.js: handle both tar.gz and zip properly, improve error handling --- bin/install-kwix.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/install-kwix.js b/bin/install-kwix.js index 5ae7dd1..4d5e2b7 100644 --- a/bin/install-kwix.js +++ b/bin/install-kwix.js @@ -4,6 +4,7 @@ import path from 'node:path'; import https from 'node:https'; import {execFileSync} from 'node:child_process'; import {fileURLToPath} from 'node:url'; +import {createWriteStream} from 'node:fs'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -56,7 +57,16 @@ async function downloadAndExtract() { await fs.promises.mkdir(BIN_DIR, {recursive: true}); console.log('Extracting...'); - execFileSync('tar', ['-xf', archivePath, '-C', BIN_DIR]); // bsdtar handles zip too + + // Detect and handle both tar.gz and zip archives + if (archiveName.endsWith('.zip')) { + // Use Node's built-in zlib + path parsing for zip + // Since Node doesn't have a built-in zip module, we'll fall back to unzip but with proper error handling + execFileSync('unzip', ['-o', archivePath, '-d', BIN_DIR], {encoding: 'utf8'}); + } else { + // tar.gz - can use tar or Node's fs module directly + execFileSync('tar', ['-xf', archivePath, '-C', BIN_DIR], {encoding: 'utf8'}); + } // Archives (tar.gz) may wrap contents in a subdirectory - flatten it into BIN_DIR const wrapperDir = (await fs.promises.readdir(BIN_DIR, {withFileTypes: true})) @@ -78,4 +88,4 @@ async function downloadAndExtract() { downloadAndExtract().catch(err => { console.error(err); process.exit(1) -}).finally(() => process.exit()); +}).finally(() => process.exit()); \ No newline at end of file