Skip to content

Commit d142c1a

Browse files
committed
fix: resolve template paths relative to package directory
1 parent 4631255 commit d142c1a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/core/installTemplate.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from "node:path";
22
import fs from "fs/promises";
3+
import { fileURLToPath } from "node:url";
34
import chalk from "chalk";
45
import ora from "ora";
56

@@ -71,7 +72,15 @@ export async function installTemplate(config) {
7172

7273
const archive = `${framework}${language || ""}.7z`;
7374

74-
const archivePath = path.join(process.cwd(), "templates", archive);
75+
// Resolve templates relative to this package first (works when installed globally or run from repo)
76+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
77+
const archivePath = path.join(__dirname, "..", "..", "templates", archive);
78+
79+
try {
80+
await fs.access(archivePath);
81+
} catch {
82+
throw new Error(`Template not found: ${archive}`);
83+
}
7584

7685
spinner.text = `Extracting template ${chalk.cyan(archive)}...`;
7786

0 commit comments

Comments
 (0)