@gridland/demo 0.2.12 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from "node:fs";
3
+ import { execSync, spawnSync } from "node:child_process";
3
4
  import { fileURLToPath } from "node:url";
4
5
  import { dirname, join } from "node:path";
5
6
 
@@ -17,7 +18,7 @@ if (!name || name === "--help" || name === "-h") {
17
18
  console.log(` ${d}`);
18
19
  }
19
20
  console.log("\nExamples:");
20
- console.log(" npx @gridland/demo ascii");
21
+ console.log(" bunx @gridland/demo ascii");
21
22
  console.log(" bunx @gridland/demo gradient");
22
23
  process.exit(name ? 0 : 1);
23
24
  }
@@ -28,5 +29,22 @@ if (!AVAILABLE_DEMOS.includes(name)) {
28
29
  process.exit(1);
29
30
  }
30
31
 
31
- const { runDemo } = await import("../dist/run.js");
32
- await runDemo(name);
32
+ // @opentui/core uses bun:ffi for the native terminal renderer, so we must run under bun
33
+ let hasBun = false;
34
+ try {
35
+ execSync("bun --version", { stdio: "ignore" });
36
+ hasBun = true;
37
+ } catch {}
38
+
39
+ if (!hasBun) {
40
+ console.error("Error: bun is required to run gridland demos.");
41
+ console.error("Install it with: curl -fsSL https://bun.sh/install | bash");
42
+ console.error("\nThen run: bunx @gridland/demo " + name);
43
+ process.exit(1);
44
+ }
45
+
46
+ const runPath = join(__dirname, "../dist/run.js");
47
+ const { status } = spawnSync("bun", ["-e", `import("${runPath}").then(m => m.runDemo("${name}"))`], {
48
+ stdio: "inherit",
49
+ });
50
+ process.exit(status ?? 1);