Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): run the CLI on Node versions without import.meta.main #7141

MergedCDVolvik(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/7141/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 4 changed files with 135 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
8 additions and 1 deletionapps/server/src/bin.tsModified
View file
@@ -12,6 +12,7 @@
import { pairCommand } from "./cli/pair.ts";
import { hasCloudPublicConfig } from "./cloud/publicConfig.ts";
import { sharedServerCommandFlags } from "./cli/config.ts";
+import { isEntrypoint } from "./entrypoint.ts";
import { projectCommand } from "./cli/project.ts";
import { runServerCommand, serveCommand, startCommand } from "./cli/server.ts";
import { serviceCommand } from "./cli/service.ts";
@@ -61,7 +62,13 @@
​
export const cli = makeCli();
​
-if (import.meta.main) {
+if (
+ isEntrypoint({
+ moduleUrl: import.meta.url,
+ entryPath: process.argv[1],
+ runtimeMain: import.meta.main,
+ })
+) {
Command.run(cli, { version: packageJson.version }).pipe(
Effect.scoped,
Effect.provide(CliRuntimeLayer),
89 additions and 0 deletionsapps/server/src/entrypoint.test.tsAdded
View file
@@ -0,0 +1,89 @@
+// @effect-diagnostics nodeBuiltinImport:off - entrypoint detection is a Node filesystem boundary.
+import * as NodeFS from "node:fs";