Fix PR feedback

Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
soupette 2022-03-23 10:39:19 +01:00 committed by Convly
parent 036a371160
commit cd9a6e4bd8
3 changed files with 4 additions and 6 deletions

View File

@ -86,7 +86,7 @@ async function createCacheDir({ appDir, plugins, useTypeScript }) {
// Retrieve the custom config file extension
const customAdminAppConfigFile = await getCustomAppConfigFile(appDir, useTypeScript);
if (customAdminAppConfigFile !== undefined) {
if (customAdminAppConfigFile) {
const defaultAdminConfigFilePath = path.resolve(cacheDir, 'admin', 'src', 'app.js');
const customAdminAppConfigFilePath = path.join(
appDir,

View File

@ -13,11 +13,9 @@ const getCustomAppConfigFile = async (dir, useTypeScript) => {
const adminSrcPath = join(dir, 'src', 'admin');
const files = await fse.readdir(adminSrcPath);
if (useTypeScript) {
return files.find(file => file.match(/app.tsx?$/));
}
const appRegex = new RegExp(`app.${useTypeScript ? 't' : 'j'}sx?$`);
return files.find(file => file.match(/app.jsx?$/));
return files.find(file => file.match(appRegex));
};
module.exports = getCustomAppConfigFile;

View File

@ -36,7 +36,7 @@ const hasCustomAdminCode = async (dir, useTypeScript) => {
const customAdminAppConfigFile = await getCustomAppConfigFile(dir, useTypeScript);
const customAdminWebpackFile = path.join(customAdminPath, 'webpack.config.js');
const hasCustomConfigFile = customAdminAppConfigFile !== undefined;
const hasCustomConfigFile = !!customAdminAppConfigFile;
const hasCustomWebpackFile = await fs.pathExists(customAdminWebpackFile);
return hasCustomConfigFile || hasCustomWebpackFile;