Skip to content

Commit

Permalink
fix(themeprepare.js): changed config folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
opensrc0 committed Feb 18, 2024
1 parent d204184 commit 80c2604
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions __application/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const getDirPath = (env, CURRENT_APP_DIR, COMPONENT_CONFIG_PATH) => {
let createDir;

if (env === 'local') {
createDir = `${CURRENT_APP_DIR}/${COMPONENT_CONFIG_PATH}/fe-theme`;
createDir = `${CURRENT_APP_DIR}/${COMPONENT_CONFIG_PATH}/fe-theme-config`;
} else {
createDir = path.resolve(`${__dirname}`, `../../../${process.env.COMPONENT_CONFIG_PATH}/fe-theme`);
createDir = path.resolve(`${__dirname}`, `../../../${process.env.COMPONENT_CONFIG_PATH}/fe-theme-config`);
}

return createDir;
Expand Down
21 changes: 7 additions & 14 deletions __appset/themePrepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,20 @@ const { CURRENT_APP_DIR } = process.env; // My project Location
const { COMPONENT_CONFIG_PATH } = process.env; // Where to place in My project Location
const { COMPONENT_NAME } = process.env;

let appDir;
if (ENVIRONMENT === 'local') {
appDir = `${CURRENT_APP_DIR}/${COMPONENT_CONFIG_PATH}fe-theme`;
} else {
appDir = path.resolve(`${__dirname}`, `../../../${process.env.COMPONENT_CONFIG_PATH}fe-theme`);
}
const dirPath = getDirPath(ENVIRONMENT, CURRENT_APP_DIR, COMPONENT_CONFIG_PATH);
const components = getComponents(COMPONENT_NAME);

const manageThemeFile = async (component, dirPath) => {
const themeFile = process.env.ENVI === 'local' ? `${appDir}/theme.js` : path.resolve(dirPath, 'theme.js');
const manageThemeFile = async (component) => {
const themeFile = `${path.resolve(dirPath)}/theme.js`;

try {
const data = await fs.promises.readFile(`${appDir}/theme.js`, 'utf8');
const data = await fs.promises.readFile(`${dirPath}/theme.js`, 'utf8');
addComponentInExistingThemeFile(component, themeFile, data);
} catch (err) {
await addComponentInNewThemeFile(component, themeFile);
}
};

const dirPath = getDirPath(ENVIRONMENT, CURRENT_APP_DIR, COMPONENT_CONFIG_PATH);
const components = getComponents(COMPONENT_NAME);

mkdirp(dirPath).then(async () => {
for (const component of components) {
if (component !== 'theme.js' && component !== 'normalise.js' && component !== 'themePrepare copy.js') {
Expand All @@ -48,9 +41,9 @@ mkdirp(dirPath).then(async () => {

components.map(async (component, index) => {
const fileData = fs.readFileSync(`${path.resolve('__appset')}/${component}`).toString();
const fileName = ENVIRONMENT === 'local' ? `${appDir}/${component}` : path.resolve(dirPath, component);
const fileName = `${path.resolve(dirPath)}/${component}`;

if (await isFileExist(appDir, component)) {
if (await isFileExist(dirPath, component)) {
fileGeneratedLog(index, fileName, true);
setUpCompletedLog(index, components.length);
return false;
Expand Down

0 comments on commit 80c2604

Please sign in to comment.