Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use generator.log in example #252

Closed
wants to merge 3 commits into from

2 participants

@stephanebachelier

remove console.log usage in example as stated in the introduction :P

@stephanebachelier stephanebachelier Use generator.log in example
remove console.log usage in example as stated in the introduction :P
ff4be6f
@SBoudrias
Owner

in this case generator is undefined. You'd need to use this.log and pass the context.

@stephanebachelier stephanebachelier generator is undefined at this point
Updated following comment from @SimonBoudrias
8764604
@stephanebachelier

@SBoudrias updated. I've added a comment.

I find it strange that in this specific case generator.log is not existing, when the documentation is saying to only use this function.

@SBoudrias
Owner

@stephanebachelier This is because generator is an instance, in this case it is this. It is not a global variable.

app/authoring/user-interactions.md
@@ -30,7 +30,9 @@ yeoman.generators.Base.extend({
message : "Your project name",
default : this.appname // Default to current folder name
}, function (answers) {
- console.log(answers.name);
+ // in this case `generator.log` is not available as `generator` is undefined
+ // so you must use `this.log` version.
+ this.log(answers.name);
done();
});
@SBoudrias Owner

.bind(this) or the context is lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stephanebachelier

@SBoudrias Ah! I understand... I should go to bed :)
Using generator.log may be somewhat confusing.

@SBoudrias
Owner

Sorry, but this doesn't work either. I fixed it 343dbda

@SBoudrias SBoudrias closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 24, 2014
  1. @stephanebachelier

    Use generator.log in example

    stephanebachelier authored
    remove console.log usage in example as stated in the introduction :P
Commits on Jun 25, 2014
  1. @stephanebachelier

    generator is undefined at this point

    stephanebachelier authored
    Updated following comment from @SimonBoudrias
  2. @stephanebachelier
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  app/authoring/user-interactions.md
View
3  app/authoring/user-interactions.md
@@ -30,7 +30,8 @@ yeoman.generators.Base.extend({
message : "Your project name",
default : this.appname // Default to current folder name
}, function (answers) {
- console.log(answers.name);
+ // do not forget to bind to current context
+ this.log(answers.name).bind(this);
done();
});
}
Something went wrong with that request. Please try again.