Skip to content

Commit

Permalink
feat(cli): use forEach to iterate files and also add new console log …
Browse files Browse the repository at this point in the history
…message
  • Loading branch information
satya-achanta-venkata committed Oct 22, 2023
1 parent b832799 commit 5984efe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/pharos-cli/src/cmds/pharos-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ const createPharosComponent = async (componentName: ComponentName): Promise<void
if (!wasError) {
console.log(colors.yellow(`\nAdding Pharos${titleCaseName} component export`));
addComponentToIndexFile(currentDirectory, nameOptions);
addComponentsToInitFile(currentDirectory, nameOptions);
console.log('\nComponent creation complete! \nHappy developing!'.cyan);
addComponentsToInitFile(currentDirectory, nameOptions);
console.log(
`\nAdded new components to initComponents files as well. You should be able to use your component without making any changes`
.green
);
} else {
console.log(
'\n@ithaka/pharos-cli encountered an error attempting to create your component\n'.red
Expand Down
2 changes: 1 addition & 1 deletion packages/pharos-cli/src/utils/generation-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const addComponentsToInitFile = (

// import new component in list of imports
// and then register new component
[unitTestsFilePath, storybookFilePath].map((filePath: FilePath) => {
[unitTestsFilePath, storybookFilePath].forEach((filePath: FilePath) => {
fs.readFile(filePath, 'utf8', function (_, data) {
const existingFileContent: string[] = data.split('} from');
const newImportStatement =
Expand Down

0 comments on commit 5984efe

Please sign in to comment.