Spaces:
Running
Running
File size: 892 Bytes
fd8cdf5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
import { existsSync } from 'node:fs';
/**
* Resolves the absolute path to the pre-built static bundle (dist/ directory).
*
* The compiled CLI lives at dist/cli/bundle-path.js.
* The Astro static output (index.html, _astro/, etc.) lives at dist/.
* So from this script's location, the bundle is one directory up.
*/
export function getBundlePath() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Navigate from dist/cli/ up to dist/
const bundlePath = resolve(__dirname, '..');
if (!existsSync(bundlePath) || !existsSync(resolve(bundlePath, 'index.html'))) {
throw new Error(`Static bundle not found at ${bundlePath}. This is a packaging error — the Astro build output (dist/) is missing.`);
}
return bundlePath;
}
|