Skip to content

Commit

Permalink
Add version to binary name (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph authored Sep 22, 2024
1 parent 90dec46 commit 7aba2a7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno-webview"
version = "0.1.4"
version = "0.1.5"
edition = "2021"

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "deno run --watch main.ts",
"gen": "cargo test && deno run -A scripts/generate-zod.ts && deno run -A scripts/sync-versions.ts",
"build": "deno task gen && cargo build -F transparent",
"example:simple": "deno run -A examples/simple.ts"
"example:simple": "WEBVIEW_BIN=./target/debug/deno-webview deno run -A examples/simple.ts"
},
"publish": {
"include": ["README.md", "LICENSE", "src/**/*.ts"]
Expand Down
4 changes: 2 additions & 2 deletions scripts/sync-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const libContent = await Deno.readTextFile(libPath);

// Replace the version in the URL
const updatedContent = libContent.replace(
/releases\/download\/v\d+\.\d+\.\d+\/deno-webview/,
`releases/download/v${latestVersion}/deno-webview`,
/const BIN_VERSION = "[^"]+"/,
`const BIN_VERSION = "${latestVersion}"`,
);

// Write the updated content back to src/lib.ts
Expand Down
7 changes: 5 additions & 2 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import type { Except } from "npm:type-fest";
import { join } from "jsr:@std/path";
import { ensureDir, exists } from "jsr:@std/fs";

/* The version of the webview binary to use; should match the cargo package version */
const BIN_VERSION = "0.1.5";

type JSON =
| string
| number
Expand Down Expand Up @@ -83,7 +86,7 @@ async function getWebViewBin(options: WebViewOptions) {
: "";

const cacheDir = getCacheDir();
const fileName = `deno-webview${flags}${
const fileName = `deno-webview-${BIN_VERSION}${flags}${
Deno.build.os === "windows" ? ".exe" : ""
}`;
const filePath = join(cacheDir, fileName);
Expand All @@ -95,7 +98,7 @@ async function getWebViewBin(options: WebViewOptions) {

// If not in cache, download it
let url =
"https://github.com/zephraph/webview/releases/download/v0.1.4/deno-webview";
`https://github.com/zephraph/webview/releases/download/v${BIN_VERSION}/deno-webview`;
switch (Deno.build.os) {
case "darwin": {
url += "-mac" + flags;
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ fn main() -> wry::Result<()> {
}
Event::MainEventsCleared => {
if let Ok(req) = rx.try_recv() {
eprintln!("Received event: {:?}", event);
match req {
Request::Eval { id, js } => {
let result = webview.evaluate_script(&js);
Expand Down

0 comments on commit 7aba2a7

Please sign in to comment.