Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 788b0a3

Browse files
committed
improve path resolution
1 parent 47031a7 commit 788b0a3

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
import path from 'path';
2-
import { fileURLToPath } from 'url';
32

4-
const currentDir = path.dirname(fileURLToPath(import.meta.url));
3+
const argvDir = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : '';
4+
const cwd = process.cwd();
5+
const baseDirCandidates = [argvDir, cwd].filter(Boolean);
56

6-
export const webappPath = path.resolve(currentDir, '../../../../build/webapp');
7-
export const indexHtml = path.resolve(webappPath, './index.html');
7+
let baseDir = cwd;
8+
for (const candidate of baseDirCandidates) {
9+
const normalized = path.normalize(candidate);
10+
if (normalized.endsWith(path.join('build', 'server'))) {
11+
baseDir = path.resolve(candidate, '..', '..');
12+
break;
13+
}
14+
if (normalized.endsWith(path.join('packages', 'server'))) {
15+
baseDir = path.resolve(candidate, '..', '..');
16+
break;
17+
}
18+
}
819

9-
export const diagramStoragePath = path.resolve(currentDir, '../../../../diagrams');
20+
const rootDir = process.env.APOLLON_BASE_DIR ? path.resolve(process.env.APOLLON_BASE_DIR) : baseDir;
21+
22+
export const webappPath = path.resolve(rootDir, 'build/webapp');
23+
export const indexHtml = path.resolve(webappPath, 'index.html');
24+
25+
export const diagramStoragePath = path.resolve(rootDir, 'diagrams');
1026

1127
export const tokenLength = 20;

0 commit comments

Comments
 (0)