generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

Generating an app from a directory named-a-lot-like-this will generate a non functioning app

Open dylanswartz opened this issue 11 years ago • 4 comments

If my current directory name is delimited by dashes/underscores/spaces AND one of the words in the name is a single letter word (like 'a' or 'i') the generated angular app will throw an exception. Reason being, the module in app.js will not be the same case as the value for ng-app index.html.

For example, if from the directory this-is-a-test I run yo angular, my generated index.html file will have ng-app="thisIsATest" and my app.js will have 'thisIsAtest' defined as the module.

Traced the life of that string through the code and came up with the following findings:

_.camelize(_.slugify(_.humanize('this-is-a-cool-app')));
'thisIsACoolApp' // gets written to index.html from app/index.js

_.slugify(_.humanize('thisIsACoolApp'));
'this-is-acool-app' // gets written to bower.json from app/index.js

// 'this-is-acool-app' // gets read from bower.json in script-base.js

 _.camelize(_.slugify(_.humanize('this-is-acool-app')));
 'thisIsAcoolApp' // gets written to app.js, main.js, etc

As you can see there's a problem with how _.humanize works with the camelcase.

I submitted this issue to the underscore.string folks: https://github.com/epeli/underscore.string/issues/289

Output of yo -version, env vars, gruntfile, etc: https://gist.github.com/dylanswartz/24549a21091b2e9e89a9

dylanswartz avatar Jun 28 '14 06:06 dylanswartz

which version of the generator

eddiemonge avatar Jun 28 '14 07:06 eddiemonge

0.9.1

dylanswartz avatar Jun 28 '14 17:06 dylanswartz

@dylanswartz the problem you identified given me some thoughts about very common problems with multiple ENOENT errors during "yo angular", link to my problem: https://github.com/yeoman/generator-angular/issues/760 others: https://github.com/npm/npm/issues/5453

I did a quick test I have reproduced this bug with 100% rate! NOTE: this is possible strictly related to Windows systems, because of its weird case sensitive folder naming strategy

when I create a folder case sensitive e.g. Ffff and then I enter with cd ffff on my command prompt I got: PS C:\Users\Piotr\Git\Ffff>, I run yo angular the bug is occuring

second test case, clean cache and folder contents, I leave the folder with cd .. then enter the folder again with cd Ffff on my command prompt I got: PS C:\Users\Piotr\Git\Ffff>, now when I run yo angular, everything working fine (Windows 7 tested on powershell or cmd or bash)

I'm pretty sure my linked problem: https://github.com/yeoman/generator-angular/issues/760 was caused by this bug, because i got git folder in my home with capital G, "Git", and I remember I sometimes entered it by manually typing git, or by using command prompt auto-completion by tab, and then the bug disappeared because it got it right by auto-completion with capital G.

@eddiemonge could you plz check it out?

piotrwitek avatar Jul 03 '14 00:07 piotrwitek

@dylanswartz nice research into this. once the above stuffs are fixed ill do a fix here

eddiemonge avatar Jul 08 '14 17:07 eddiemonge