-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUGFIX] ember init
fails on NULL_PROJECT
#546
Conversation
@@ -23,7 +23,7 @@ module.exports = new Command({ | |||
var installBlueprint = environment.tasks.installBlueprint; | |||
var npmInstall = environment.tasks.npmInstall; | |||
var bowerInstall = environment.tasks.bowerInstall; | |||
var packageName = environment.project ? environment.project.pkg.name : path.basename(cwd); | |||
var packageName = environment.project.isEmberCLIProject() ? environment.project.pkg.name : path.basename(cwd); |
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.
Make project a var, I'm not a fan of lines that long
var project = environment.project;
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.
sure.
@twokul I did this at the beginning but it was breaking |
@abuiles it works. |
@twokul 👍 thanks! |
@@ -23,7 +23,8 @@ module.exports = new Command({ | |||
var installBlueprint = environment.tasks.installBlueprint; | |||
var npmInstall = environment.tasks.npmInstall; | |||
var bowerInstall = environment.tasks.bowerInstall; | |||
var packageName = environment.project ? environment.project.pkg.name : path.basename(cwd); | |||
var project = environment.project; | |||
var packageName = project.isEmberCLIProject() ? environment.project.pkg.name : path.basename(cwd); |
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.
i would prefer if the null project return a null package name, as the null pattern is to reduce such branching.
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.
project.isEmberCLIProject() ? environment.project.pkg.name : path.basename(cwd);
-> project.isEmberCLIProject() ? project.pkg.name : path.basename(cwd);
@stefanpenner I'm not so sure if we should extend the NULL_PROJECT to include these things. I even think that the pkg === undefined
is the desired thing because the file really doesn't exist.
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.
I can change it to something like:
var packageName = project.name();
// ...
if (!packageName) {
packageName = path.basename(cwd);
}
That will reduce branching.
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.
but I'm generally ok with
project.isEmberCLIProject() ? environment.project.pkg.name : path.basename(cwd);
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.
kinda seems like if no name exists, the NULL_PROJECT's name should be set to basename of root, and root should be the cwd
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.
No need to clutter Project
with this special case. It's already a one-liner.
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.
@MajorBreakfast i think that is the point of this pattern
LGTM |
name: function() { | ||
return 'test'; | ||
}, | ||
isEmberCLIProject: function() { |
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.
probably isEmberCLIProject
is not longer required here ?
@@ -33,6 +33,10 @@ NULL_PROJECT.isEmberCLIProject = function() { | |||
return false; | |||
}; | |||
|
|||
Project.prototype.name = function() { | |||
return path.basename(process.cwd()); |
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 is not correct, this is the behavior only of the NULL_PROJECT, otherwise name should come form this.pkg.name
@twokul LGTM @rjackson @stefanpenner @MajorBreakfast mind giving a last look before merging . |
@abuiles thanks for the feedback |
[BUGFIX] `ember init` fails on `NULL_PROJECT`
Previously, if you try to run
ember init
inside an empty directory, it willfail because
environment.project
was not set toNULL_PROJECT
.Steps:
thanks to @abuiles for initial spike, #529
Closes #540