chore: Switched to bundling technique for grabbing templates
a3f43810
1 file(s) · +19 −1
| 1 | + | import { fileURLToPath } from "node:url"; |
|
| 2 | + | import path from "node:path"; |
|
| 3 | + | ||
| 1 | 4 | export const DEFAULT_REPO = "stevedylandev/bhvr"; |
|
| 2 | - | export const EXTRAS_DIR = "./templates/extras"; |
|
| 5 | + | ||
| 6 | + | // Resolve EXTRAS_DIR relative to this file's location |
|
| 7 | + | // We need to handle both development and production cases: |
|
| 8 | + | // - Development: running from src/ directory |
|
| 9 | + | // - Production: bundled into dist/index.js |
|
| 10 | + | const __filename = fileURLToPath(import.meta.url); |
|
| 11 | + | const __dirname = path.dirname(__filename); |
|
| 12 | + | ||
| 13 | + | // Check if we're running from source or built version |
|
| 14 | + | // In development, __dirname will contain 'src', in production it won't |
|
| 15 | + | const isProduction = !__dirname.includes(path.sep + 'src' + path.sep); |
|
| 16 | + | const templatesPath = isProduction |
|
| 17 | + | ? path.resolve(__dirname, "templates", "extras") // dist/index.js -> dist/templates/extras |
|
| 18 | + | : path.resolve(__dirname, "..", "templates", "extras"); // src/utils -> src/templates/extras |
|
| 19 | + | ||
| 20 | + | export const EXTRAS_DIR = templatesPath; |