Skip to content

Commit b438181

Browse files
committed
build: fix cli version
1 parent bdf0dfd commit b438181

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

build.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export default defineBuildConfig({
2424
].map((adapter) => `src/adapters/${adapter}.ts`),
2525
],
2626
rolldown: {
27-
define: {
28-
"globalThis.__srvx_version__": JSON.stringify(pkg.version),
29-
},
3027
external: ["bun", "@cloudflare/workers-types"],
3128
plugins: [
3229
pkg.name === "srvx-nightly" && {

src/cli.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createReadStream, existsSync } from "node:fs";
77
import { Readable } from "node:stream";
88
import * as c from "./_color.ts";
99
import { loadServerEntry } from "./loader.ts";
10+
import pkg from "../package.json" with { type: "json" };
1011

1112
// prettier-ignore
1213
const defaultEntries = ["server", "index", "src/server", "src/index", "server/index"];
@@ -27,7 +28,7 @@ export async function main(mainOpts: MainOpts): Promise<void> {
2728

2829
// Handle version flag
2930
if (options._version) {
30-
console.log(await version());
31+
console.log(version());
3132
process.exit(0);
3233
}
3334
// Handle help flag
@@ -295,7 +296,6 @@ async function serve() {
295296
}
296297

297298
declare global {
298-
var __srvx_version__: string | undefined;
299299
var __srvx__: Server;
300300
var __srvx_listen_cb__: () => void;
301301
}
@@ -373,9 +373,8 @@ function printInfo(
373373
console.log(c.gray(`${c.bold(c.gray("∘"))} Static files: ${staticInfo}`));
374374
}
375375

376-
async function version() {
377-
const version = globalThis.__srvx_version__ || "unknown";
378-
return `srvx ${version}\n${runtime()}`;
376+
function version() {
377+
return `srvx ${pkg.version}\n${runtime()}`;
379378
}
380379

381380
function runtime() {

0 commit comments

Comments
 (0)