Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HWI download on windows #38

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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