mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	 2189df9c05
			
		
	
	
		2189df9c05
		
			
		
	
	
	
	
		
			
			Checking if folder src/admin exists before checking for files inside. Committer: Cleber Jose de Rossi Changes to be committed: modified: packages/core/admin/utils/__tests__/get-custom-app-config-file.test.js modified: packages/core/admin/utils/get-custom-app-config-file.js
		
			
				
	
	
		
			34 lines
		
	
	
		
			824 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			824 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const { join } = require('path');
 | |
| const fse = require('fs-extra');
 | |
| const { isUsingTypeScript } = require('@strapi/typescript-utils');
 | |
| 
 | |
| /**
 | |
|  * Retrieve the custom admin entry file name
 | |
|  * @param {String} dir - Directory of the admin panel
 | |
|  * @returns String
 | |
|  */
 | |
| const getCustomAppConfigFile = async (dir) => {
 | |
|   const adminSrcPath = join(dir, 'src', 'admin');
 | |
| 
 | |
|   if (!fse.pathExistsSync(adminSrcPath)) {
 | |
|     return undefined;
 | |
|   }
 | |
| 
 | |
|   const useTypeScript = await isUsingTypeScript(adminSrcPath, 'tsconfig.json');
 | |
| 
 | |
|   const files = await fse.readdir(adminSrcPath);
 | |
| 
 | |
|   const appJsx = files.find((file) => /^app.jsx?$/.test(file));
 | |
|   const appTsx = files.find((file) => /^app.tsx?$/.test(file));
 | |
| 
 | |
|   if (useTypeScript) {
 | |
|     return appTsx || appJsx;
 | |
|   }
 | |
| 
 | |
|   return appJsx;
 | |
| };
 | |
| 
 | |
| module.exports = getCustomAppConfigFile;
 |