Skip to content

Commit

Permalink
Merge pull request #38 from bithyve/fix-windows-hwi-download
Browse files Browse the repository at this point in the history
Fix HWI download on windows
  • Loading branch information
ben-kaufman authored Oct 6, 2024
2 parents 2cf9940 + db22be6 commit 2b49f1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,md}'",
"format:check": "prettier --check 'src/**/*.{js,jsx,ts,tsx,json,css,md}'",
"get-hwi": "rimraf src-tauri/binaries/hwi-* && tsx scripts/get-hwi.ts",
"get-hwi": "tsx scripts/get-hwi.ts --cleanup",
"postinstall": "tsx scripts/get-hwi.ts",
"tauri:lint": "cd src-tauri && cargo clippy --all-targets --all-features -- -D warnings",
"tauri:format": "cd src-tauri && cargo fmt",
Expand Down
21 changes: 16 additions & 5 deletions scripts/get-hwi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,19 @@ async function shouldDownloadBinaries(): Promise<boolean> {
}
}

async function main() {
async function main(shouldCleanup: boolean = false) {
console.log("Starting HWI binary process...");
try {
const isEmpty = await shouldDownloadBinaries();
if (!isEmpty) {
if (shouldCleanup) {
console.log("Cleanup flag set. Cleaning up old binaries...");
await cleanDirectory(BINARY_DIR);
console.log("Cleanup completed.");
} else {
console.log("Skipping cleanup.");
}

const shouldDownload = await shouldDownloadBinaries();
if (!shouldDownload) {
console.log(
"src-tauri/binaries already has all HWI binaries. Skipping download.",
);
Expand Down Expand Up @@ -282,8 +291,10 @@ async function main() {
}
}

if (import.meta.url === `file://${encodeURI(process.argv[1])}`) {
main().catch((error) => {
if (import.meta.url.startsWith("file:")) {
const args = process.argv.slice(2);
const shouldCleanup = args.includes("--cleanup");
main(shouldCleanup).catch((error) => {
console.error("An error occurred:", error);
process.exit(1);
});
Expand Down

0 comments on commit 2b49f1c

Please sign in to comment.