Skip to content

Commit 84e79da

Browse files
committed
fix: prevent local link overwriting in smoke tests and improve runtime selection logic for cli runner
1 parent 5e715af commit 84e79da

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

packages/cli/src/utils/runner.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "fs";
22
import path from "path";
33
import { spawn } from "child_process";
44
import { createRequire } from "module";
5+
import { hasCommand } from "@portosaur/core";
56

67
/**
78
* Generates a static Docusaurus config file by evaluating the Portosaur config
@@ -174,7 +175,11 @@ export async function runDocusaurus(
174175
args.push(...extraArgs);
175176

176177
// Use bun when available for faster builds, fall back to node.
177-
const runtime = typeof Bun !== "undefined" ? "bun" : "node";
178+
// If node isn't installed, fallback to bun gracefully.
179+
let runtime = "node";
180+
if (typeof Bun !== "undefined" || !hasCommand("node")) {
181+
runtime = "bun";
182+
}
178183

179184
// Skip actual execution in test mode
180185
if (process.env.PORTO_TEST_MODE === "true") {
@@ -186,10 +191,6 @@ export async function runDocusaurus(
186191

187192
const childEnv = { ...process.env, FORCE_COLOR: "true" };
188193

189-
if (command === "build") {
190-
childEnv.CI = "true";
191-
}
192-
193194
const child = spawn(runtime, args, {
194195
stdio: "inherit",
195196
cwd: UserRoot,

src/scripts/smoke-test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ bun run "$REPO_ROOT/packages/cli/bin/porto.mjs" init \
2323
# --- Link local packages into the new project ---
2424
echo "📦 Installing local packages..."
2525
cd "$SITE_DIR"
26+
27+
# Prevent manual developer runs (e.g. bun run dev) from overwriting local links
28+
# by stripping the auto-install step from package scripts
29+
sed -i 's/$npm_execpath install && //' package.json
30+
2631
bun install
2732
bun link @portosaur/cli @portosaur/theme @portosaur/core @portosaur/logger @portosaur/wizard
2833

0 commit comments

Comments
 (0)