Skip to content

Commit

Permalink
chore(admin): simplify user customisation loading
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed Nov 14, 2023
1 parent 8ac0ef5 commit 5378a56
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path';
import { loadFile } from './files';
import fs from 'node:fs';

const ADMIN_APP_FILES = ['app.js', 'app.mjs', 'app.ts', 'app.jsx', 'app.tsx'];

Expand All @@ -12,16 +12,14 @@ interface AdminCustomisations {

interface AppFile {
path: string;
config: AdminCustomisations['config'];
}

const loadUserAppFile = async (appDir: string): Promise<AppFile | undefined> => {
for (const file of ADMIN_APP_FILES) {
const filePath = path.join(appDir, 'src', 'admin', file);
const configFile = await loadFile(filePath);

if (configFile) {
return { path: filePath, config: configFile };
if (fs.existsSync(filePath)) {
return { path: filePath };
}
}

Expand Down

0 comments on commit 5378a56

Please sign in to comment.