Spaces:
Running
Running
File size: 820 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 bundled assets directory.
*
* The compiled CLI lives at dist/cli/cli/assets-path.js.
* The assets are copied to dist/assets/ during build.
* So from this script's location, assets are at ../../assets/
*/
export function getAssetsPath() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Navigate from dist/cli/cli/ up to dist/, then into assets/
const assetsPath = resolve(__dirname, '..', '..', 'assets');
if (!existsSync(assetsPath)) {
throw new Error(`Assets directory not found at ${assetsPath}. Run "npm run build:all" to bundle assets.`);
}
return assetsPath;
}
|