@@ -18,27 +18,20 @@ const { CURRENT_APP_DIR } = process.env; // My project Location
1818const { COMPONENT_CONFIG_PATH } = process . env ; // Where to place in My project Location
1919const { COMPONENT_NAME } = process . env ;
2020
21- let appDir ;
22- if ( ENVIRONMENT === 'local' ) {
23- appDir = `${ CURRENT_APP_DIR } /${ COMPONENT_CONFIG_PATH } fe-theme` ;
24- } else {
25- appDir = path . resolve ( `${ __dirname } ` , `../../../${ process . env . COMPONENT_CONFIG_PATH } fe-theme` ) ;
26- }
21+ const dirPath = getDirPath ( ENVIRONMENT , CURRENT_APP_DIR , COMPONENT_CONFIG_PATH ) ;
22+ const components = getComponents ( COMPONENT_NAME ) ;
2723
28- const manageThemeFile = async ( component , dirPath ) => {
29- const themeFile = process . env . ENVI === 'local' ? `${ appDir } /theme.js` : path . resolve ( dirPath , ' theme.js' ) ;
24+ const manageThemeFile = async ( component ) => {
25+ const themeFile = `${ path . resolve ( dirPath ) } / theme.js` ;
3026
3127 try {
32- const data = await fs . promises . readFile ( `${ appDir } /theme.js` , 'utf8' ) ;
28+ const data = await fs . promises . readFile ( `${ dirPath } /theme.js` , 'utf8' ) ;
3329 addComponentInExistingThemeFile ( component , themeFile , data ) ;
3430 } catch ( err ) {
3531 await addComponentInNewThemeFile ( component , themeFile ) ;
3632 }
3733} ;
3834
39- const dirPath = getDirPath ( ENVIRONMENT , CURRENT_APP_DIR , COMPONENT_CONFIG_PATH ) ;
40- const components = getComponents ( COMPONENT_NAME ) ;
41-
4235mkdirp ( dirPath ) . then ( async ( ) => {
4336 for ( const component of components ) {
4437 if ( component !== 'theme.js' && component !== 'normalise.js' && component !== 'themePrepare copy.js' ) {
@@ -48,9 +41,9 @@ mkdirp(dirPath).then(async () => {
4841
4942 components . map ( async ( component , index ) => {
5043 const fileData = fs . readFileSync ( `${ path . resolve ( '__appset' ) } /${ component } ` ) . toString ( ) ;
51- const fileName = ENVIRONMENT === 'local' ? `${ appDir } /${ component } ` : path . resolve ( dirPath , component ) ;
44+ const fileName = `${ path . resolve ( dirPath ) } /${ component } ` ;
5245
53- if ( await isFileExist ( appDir , component ) ) {
46+ if ( await isFileExist ( dirPath , component ) ) {
5447 fileGeneratedLog ( index , fileName , true ) ;
5548 setUpCompletedLog ( index , components . length ) ;
5649 return false ;
0 commit comments