Skip to content

Commit

Permalink
fix: fix components add command
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Klesse committed Oct 15, 2024
1 parent f7a4945 commit 9537965
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/commands/components/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ const AddComponentCommand: GluegunCommand = {
},
};

async function getConfigForComponent(fileName: string) {
async function getConfigForComponent(fileName: string, toolbox: ExtendedGluegunToolbox) {
const { print } = toolbox;
const configSpinner = print.spin(`Checking the config for component...`);

const data = await getConfig();
const name = fileName.split('.').slice(0, -1).join('.');
return data.config[name] || {};
const rootName = name.split('/')[0];

configSpinner.succeed(`Config for ${rootName} loaded successfully`);
return data.config[rootName] || {};
}

async function getConfig() {
Expand Down Expand Up @@ -183,9 +189,7 @@ async function copyComponent(file: { name: string; type: 'dir' | 'file' }, toolb

return new Promise(async (resolve, reject) => {
try {
const configSpinner = print.spin(`Checking the config for ${file.name}...`);
const config = await getConfigForComponent(file.name);
configSpinner.succeed(`Config for ${file.name} loaded successfully`);
const config = await getConfigForComponent(file.name, toolbox);

if (config) {
await processConfig(config, toolbox);
Expand Down

0 comments on commit 9537965

Please sign in to comment.