cgross / generator-cg-angular

Yeoman generator for Enterprise Angular projects.
MIT License
592 stars 198 forks source link

Directives not saving their names to files, causes conflicts with simple directives #19

Closed 34r7h closed 10 years ago

34r7h commented 10 years ago

Kudos on the new build! It's just about perfect, tho there's a bug in saving the directive file names on my build.

For complex directives, everything wires up fine throughout the generation but filenames are all directive.* instead of the terminal command name. This causes a conflict with simple directives saving to the same folder since they are both directive.js.

The stubborn workaround of course is to rename the files manually then change the references in index.html and app.less.

Cheers and really stellar job all in all!

Output from terminal for simple directive, notice file names

$ yo cg-angular:directive checkin [?] Does this directive need an external html file (i.e. partial)? No
[?] Where would you like to create the directive files? directive/
updating index.html create directive/directive-spec.js create directive/directive.js

Output from terminal for simple directive, file names

$ yo cg-angular:directive cart
[?] Does this directive need an external html file (i.e. partial)? Yes
[?] Where would you like to create the directive files? directive/cart/
updating index.html updating app.less create directive/cart/directive-spec.js create directive/cart/directive.html create directive/cart/directive.js create directive/cart/directive.less

And in that resulting directive.js

angular.module('ecopos').directive('cart', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {

        },
        templateUrl: 'cart/cart.html',
        link: function(scope, element, attrs, fn) {

        }
    };
});
cgross commented 10 years ago

Yup this was a bug. Thank the report. I've published the fix.

34r7h commented 10 years ago

Much excellent!

34r7h commented 10 years ago

This is probably related but def not a priority.. the directive js templateUrl's reference stays in directive/ when you send it to a different location. All the other wiring still works, just a quick manual correction in the directive js fixes.

cgross commented 10 years ago

Doh. I was working too fast and should have caught that as well. I just fixed it and published again. Thanks again.

34r7h commented 10 years ago

hehe no good deed... i'm getting the following error now with the directive subgen:

o$ yo cg-angular:directive calendarnoios-MacBook-Air:www io$ yo cg-angular:directive calendar [?] Does this directive need an external html file (i.e. partial)? Yes
[?] Where would you like to create the directive files? undefined/calendar/

/usr/local/lib/node_modules/generator-cg-angular/utils.js:83 var config = that.config.get('inject')[ext]; ^ TypeError: Cannot read property 'html' of undefined at Object.exports.inject (/usr/local/lib/node_modules/generator-cg-angular/utils.js:83:43) at /usr/local/lib/nodemodules/generator-cg-angular/utils.js:69:21 at Array.forEach (native) at Function..each._.forEach (/usr/local/lib/node_modules/generator-cg-angular/nodemodules/underscore/underscore.js:79:11) at .(anonymous function) as each at Object.exports.processTemplates (/usr/local/lib/node_modules/generator-cg-angular/utils.js:63:10) at DirectiveGenerator.files (/usr/local/lib/node_modules/generator-cg-angular/directive/index.js:72:13) at /usr/local/lib/node_modules/generator-cg-angular/node_modules/yeoman-generator/lib/base.js:341:43 at /usr/local/lib/node_modules/generator-cg-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:551:21

cgross commented 10 years ago

Did you do something to you .yo-rc.json file? It looks like its gone or corrupted? The generator pulls various values from that file.

On Tue, Mar 11, 2014 at 4:31 PM, irthos notifications@github.com wrote:

hehe no good deed... i'm getting the following error now with the directive subgen:

o$ yo cg-angular:directive calendarnoios-MacBook-Air:www io$ yo cg-angular:directive calendar

[?] Does this directive need an external html file (i.e. partial)? Yes

[?] Where would you like to create the directive files? undefined/calendar/

/usr/local/lib/node_modules/generator-cg-angular/utils.js:83 var config = that.config.get('inject')[ext]; ^ TypeError: Cannot read property 'html' of undefined at Object.exports.inject (/usr/local/lib/node_modules/generator-cg-angular/utils.js:83:43) at /usr/local/lib/nodemodules/generator-cg-angular/utils.js:69:21 at Array.forEach (native) at Function..each._.forEach (/usr/local/lib/node_modules/generator-cg-angular/nodemodules/underscore/underscore.js:79:11) at .(anonymous function) as each http://usr/local/lib/node_modules/generator-cg-angular/node_modules/underscore/underscore.js:1123:39 at Object.exports.processTemplates (/usr/local/lib/node_ modules/generator-cg-angular/utils.js:63:10) at DirectiveGenerator.files (/usr/local/lib/node_modules/generator-cg-angular/directive/index.js:72:13) at /usr/local/lib/node_modules/generator-cg-angular/node_modules/yeoman-generator/lib/base.js:341:43 at /usr/local/lib/node_modules/generator-cg-angular/node_modules/yeoman-generator/node_modules/async/lib/async.js:551:21

Reply to this email directly or view it on GitHubhttps://github.com/cgross/generator-cg-angular/issues/19#issuecomment-37345890 .

34r7h commented 10 years ago

Thank you, forgot that file while moving dirs. Thanks for being there! Owes ya 1!