-
-
Notifications
You must be signed in to change notification settings - Fork 372
initialize new projects with git init if git present
#35
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
Conversation
|
I would add several more patterns to gitignore:
The default gitignore for node might have some more goodies but frankly I haven't seen half of those files in any node project. |
|
^^ With |
|
I remember npm generating timestamps in log file names but it doesn't do so anymore (at least I don't remember how it is done) so probably they are not needed. :) |
src/commands/create.js
Outdated
| // Initializes the folder using `git init` and a proper `.gitignore` file | ||
| // if `git` is present in the $PATH. | ||
| const initializeVersionControl = async function(target) { | ||
| if (which.sync('git')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which.sync throws an error if command is not found according to the docs. Is the exception swallowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be using the async version of which. Here's how:
import promisify from 'es6-promisify';
// ...
async function initializeVersionControl(target) {
let git;
try {
git = await promisify(which)('git');
}
catch (err) {}
if (!git) {
// ... etc
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this have to be async? It would throw in either case when using async/await.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to avoid blocking (nothing else is blocking in the CLI).
| await spawn('git', ['init'], { cwd }); | ||
| await spawn('git', ['add', '-A'], { cwd }); | ||
|
|
||
| const gitUser = 'Preact CLI<[email protected]>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh - I am wondering if this will spam me with notifications 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of dear !! That sure will. Good luck with that !!
|
Overall this is great! Thanks for doing all the work, haha. Only thing I'm keen to add to this aside from the little sync fix would be a |
lukeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I would like to see a which abstraction that handles its own error case -- especially now that we have conditional Yarn usage.
I can add this in post-merge if needed.
|
@lukeed agreed, it would be nice to have |
|
@developit @lukeed it's here - https://github.com/developit/preact-cli/pull/31/files#diff-3d03cf8df0979b4050f3a105cfd861c5R168 . |
|
wow I even subconsciously stole the name. One thought I had regarding the original topic here - what do we think of actually using git to clone starter projects? I believe Thoughts? I think they were using a module that handled like 90% of the work too. |
|
I think this makes more sense to be paired up with #56 as a minor or even major. |
fixes #28
i may have also extracted that
trimLeftfunctionality