Files
RedditBot/src/web/dashboard-assets.ts
T

35 lines
845 B
TypeScript

import fs from 'node:fs';
import path from 'node:path';
export interface DashboardAssets {
directory: string;
indexFile: string;
isLegacy: boolean;
}
export type FileExists = (filePath: string) => boolean;
export function resolveDashboardAssets(
workspaceDirectory: string,
fileExists: FileExists = fs.existsSync,
): DashboardAssets {
const reactDirectory = path.join(workspaceDirectory, 'apps', 'dashboard', 'dist');
const reactIndexFile = path.join(reactDirectory, 'index.html');
if (fileExists(reactIndexFile)) {
return {
directory: reactDirectory,
indexFile: reactIndexFile,
isLegacy: false,
};
}
const legacyDirectory = path.join(workspaceDirectory, 'public');
return {
directory: legacyDirectory,
indexFile: path.join(legacyDirectory, 'index.html'),
isLegacy: true,
};
}