Skip to content

Commit

Permalink
fix: log everything at once
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Jan 3, 2024
1 parent 9bc868e commit 50a5627
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions __e2e__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ test('init should ask and print files in directory if exist', () => {

const {stdout, stderr} = runCLI(DIR, ['init', PROJECT_NAME]);

console.log({
stdout,
stderr,
});

expect(stdout).toContain(`Do you want to replace existing files?`);
expect(stderr).toContain(
`warn The directory ${PROJECT_NAME} contains files that will be overwritten:`,
);
expect(stdout).toContain(`package.json`);
expect(stdout).toContain(`Do you want to replace existing files?`);
expect(stderr).toContain(`package.json`);
});

test('init should prompt for the project name', () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ async function setProjectDirectory(
const conflicts = getConflictsForDirectory(directory);

if (conflicts.length > 0) {
logger.warn(
`The directory ${chalk.bold(
directory,
)} contains files that will be overwritten:`,
);
let warnMessage = `The directory ${chalk.bold(
directory,
)} contains files that will be overwritten:\n`;

for (const conflict of conflicts) {
logger.log(` ${conflict}`);
warnMessage += ` ${conflict}\n`;
}

logger.warn(warnMessage);

const {replace} = await prompt({
type: 'confirm',
name: 'replace',
Expand Down

0 comments on commit 50a5627

Please sign in to comment.