Skip to content

Commit

Permalink
fix: forEach에서 for...of 구문으로 변경해 동기적으로 실행되도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ghdtjgus76 committed Apr 16, 2024
1 parent 21bde95 commit 27ad3a5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/cli/src/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { writeFileWithContent } from "../utils/writeFileWithContent.js";
import { getRegistryInfo } from "../utils/getRegistryInfo.js";
import { isInitialized } from "../utils/isInitialized.js";

// TODO 컴포넌트 여러 개 설치 시 의존성 제대로 다운로드 안 되는 문제 해결 필요
const addOptionsSchema = z.object({
components: z.array(z.string()).optional(),
cwd: z.string(),
Expand Down Expand Up @@ -72,7 +73,7 @@ export const add = program
selectedComponents = components;
}

selectedComponents?.forEach(async (component) => {
for (const component of selectedComponents) {
const componentInfo = await getComponentInfo(component);

if (!componentInfo) {
Expand All @@ -83,7 +84,7 @@ export const add = program
const spinner = ora(`Installing... ${component}`).start();

const file = componentInfo.files[0];
const dir = path.join(options.path, "components", "ui");
const dir = path.join(options.path, "components");
const { content: fileContent, name: fileName } = file;
const filePath = path.join(dir, fileName);
const dependencies = componentInfo.dependencies;
Expand All @@ -98,7 +99,7 @@ export const add = program
}

writeFileWithContent(filePath, fileContent);
installDependencies(
await installDependencies(
packageManager,
dependencies,
options.path,
Expand All @@ -109,11 +110,16 @@ export const add = program
});
} else {
writeFileWithContent(filePath, fileContent);
installDependencies(packageManager, dependencies, options.path, () => {
spinner.succeed(`${component} installed successfully.`);
});
await installDependencies(
packageManager,
dependencies,
options.path,
() => {
spinner.succeed(`${component} installed successfully.`);
}
);
}
});
}
});

program.parse();

0 comments on commit 27ad3a5

Please sign in to comment.