yeoman / generator-angular

Yeoman generator for AngularJS
http://yeoman.io
5.73k stars 1.44k forks source link

Creating a decorator throws an exception #594

Closed magnifi closed 10 years ago

magnifi commented 10 years ago

using the regular command yo angular:decorator DECORATOR_NAME throws the following exception:

SyntaxError: Unexpected token ILLEGAL
at Function (<anonymous>)
at Function.template (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/lodash/dist/lodash.js:5158:22)
at Generator.underscore [as _engine] (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/lib/util/engines.js:33:14)
at Generator.engine (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/lib/actions/actions.js:291:10)
at Generator.template (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/lib/actions/actions.js:269:15)
at Generator.appTemplate (/usr/local/lib/node_modules/generator-angular/script-base.js:72:45)
at Generator.createDecoratorFiles (/usr/local/lib/node_modules/generator-angular/decorator/index.js:61:8)
at /usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/lib/base.js:290:20
at /usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:551:21
at /usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:227:13
eddiemonge commented 10 years ago

Is that the exact name you are using?

magnifi commented 10 years ago

of course not, I have tried auth, auth-interceptor, ... I have tried every other sub-generator, and only decorators seem to have this issue.

eggers commented 10 years ago

Do you have a matching provider? You'll get an error without. Don't remember if it is that error or a different one.

eddiemonge commented 10 years ago

@magnifi Are you still having this issue? Did egger's comment help?

magnifi commented 10 years ago

@eddiemonge , Unfortunately it did not, I have to create the decorator manually, and also the exception seems a little bit vague. This is how I produce the issue:

1- Create a provider called auth: yo angular:provider auth 2- Create a service decorator: yo angular:decorator auth-decorator.

eddiemonge commented 10 years ago

The decorator needs to have the same name as the provider. The correct sequence should look like:

yo angular:provider auth
yo angular:decorator auth
magnifi commented 10 years ago

@eddiemonge I have tried this first, but it still get the same error. This could be another dependency issue, but I am not sure of that.

eddiemonge commented 10 years ago

Try it again and see if it still happens. If it does, try generating a new project and then running those commands there

magnifi commented 10 years ago

OK, I have created a new project and tried the commands. It seems that the issue only appears with CoffeeScript, and works as expected with JS.

here are the commands I have tried:

yo angular:app && yo angular:provider auth && yo angular:decorator auth

however this did not work: yo angular:app --coffee && yo angular:provider auth && yo angular:decorator auth

magnifi commented 10 years ago

I think I have found the issue, it is in the decorator template angular.module("<%= scriptAppName").config ($provide) -> it is missing the closing tag.

eddiemonge commented 10 years ago

Thats been fixed in master and will be in the next release

magnifi commented 10 years ago

OK, I have seen that.

Thank you.