Skip to content

fix: display real value for the directory to cd to after init#415

Merged
lucacasonato merged 2 commits into
freshframework:mainfrom
dikarel:dikarel/fixinitmessage
Jul 5, 2022
Merged

fix: display real value for the directory to cd to after init#415
lucacasonato merged 2 commits into
freshframework:mainfrom
dikarel:dikarel/fixinitmessage

Conversation

@dikarel

@dikarel dikarel commented Jul 4, 2022

Copy link
Copy Markdown
Contributor
Before After
Screen Shot 2022-07-04 at 3 23 05 PM Screen Shot 2022-07-04 at 3 22 31 PM

Fixes the output of the init script, so that it instructs the user to cd into the directory that the user specifies (rather than a hard-coded my-project)

Why this change?

It can be confusing to the user to see a prompt to cd to my-project, when the user specifies a different directory for init. It's extra confusing for folks who are newer to programming or are trying to on-board by following tutorials, so I think this might hurt adoption if not fixed.

Test plan:

  • Run deno fmt init.ts to catch lint violations
  • Run deno task test to catch test failures
  • Run deno run -A init.ts todo-list to verify that the cd message is correct

@dikarel dikarel changed the title Dikarel/fixinitmessage init.ts: Prompt users to cd to the directory that they actually specified, rather than "my-project" Jul 4, 2022
Comment thread init.ts
await Deno.mkdir(join(directory, ".vscode"), { recursive: true });
await Deno.mkdir(join(resolvedDirectory, ".vscode"), { recursive: true });
}
if (useTwind) {

@dikarel dikarel Jul 4, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This re-format came from deno fmt. I think the rename of directory has caused the original line to exceed a column limit?

Comment thread init.ts
}
const IMPORT_MAP_JSON = JSON.stringify(importMap, null, 2) + "\n";
await Deno.writeTextFile(join(directory, "import_map.json"), IMPORT_MAP_JSON);
await Deno.writeTextFile(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This re-format also came from deno fmt

@dikarel dikarel changed the title init.ts: Prompt users to cd to the directory that they actually specified, rather than "my-project" fix: Have init.ts prompt users to cd to the directory that they actually specified, rather than "my-project" Jul 4, 2022
Comment thread init.ts
// not leak personal info (e.g. `/Users/MyName`)
console.log("\n%cProject created!", "color: green; font-weight: bold");
console.log("\`cd my-project\` to enter to the project directory.");
console.log(`\`cd ${unresolvedDirectory}\` to enter to the project directory.`);

@dikarel dikarel Jul 4, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternate approach: Why not just print Deno.args[0] here?

I think that would make the concern of reading from command line args less DRY. "reading from command line args" feels like one of those areas where making a mistake would be impactful, so it felt important to optimize for DRY-ness there.

@lucacasonato lucacasonato left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@lucacasonato lucacasonato changed the title fix: Have init.ts prompt users to cd to the directory that they actually specified, rather than "my-project" fix: display real value for the directory to cd to after init Jul 5, 2022
@lucacasonato lucacasonato merged commit 86daf73 into freshframework:main Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants