strapi/packages/core/admin/utils/get-custom-app-config-file.js

22 lines
616 B
JavaScript
Raw Normal View History

'use strict';
const { join } = require('path');
const fse = require('fs-extra');
/**
* Retrieve the custom admin entry file name
* @param {String} dir - Directory of the admin panel
* @param {Boolean} useTypeScript - Does the custom admin entry file use TS
* @returns String
*/
const getCustomAppConfigFile = async (dir, useTypeScript) => {
const adminSrcPath = join(dir, 'src', 'admin');
const files = await fse.readdir(adminSrcPath);
const appRegex = new RegExp(`app.${useTypeScript ? 't' : 'j'}sx?$`);
return files.find(file => file.match(appRegex));
};
module.exports = getCustomAppConfigFile;