Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor init package #1050

Closed
3 tasks
thescientist13 opened this issue Feb 5, 2023 · 1 comment
Closed
3 tasks

refactor init package #1050

thescientist13 opened this issue Feb 5, 2023 · 1 comment
Labels
enhancement Improve something existing (e.g. no docs, new APIs, etc) good first issue Good for newcomers Init
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Feb 5, 2023

Type of Change

Enhancement

Summary

The current init package uses a lot of instances of mixed sync and async languages, often times in "conflict" with each other, for example

await Promise.all(
  templateFiles.map(async file => {
    const resolvedPath = path.join(templateDir, file);
    
    if (fs.lstatSync(resolvedPath).isDirectory()) {
      return await copyFolder(resolvedPath, TARGET_DIR);
    } else if (await fs.existsSync(resolvedPath)) {
      return await fs.copyFileSync(
        resolvedPath,
        path.join(TARGET_DIR, file)
      );
    }
  })
);

Details

So would be good to do some refactoring

  1. Consistent usage of async / await, use for ... of loops to make things cleaner
  2. Leverage URL+ fs.promises as much as possible instead of path
  3. See if we can leverage more out of the box fs operations for copying functionality
@thescientist13
Copy link
Member Author

I think in light of #1279, there will be a significant amount of rewriting anyway, and so by nature of working on that, I anticipate things will get refactored automatically, so can defer this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve something existing (e.g. no docs, new APIs, etc) good first issue Good for newcomers Init
Projects
No open projects
Development

No branches or pull requests

1 participant