yeoman / generator-angular

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

Windows directory separator now is backslash - wrong paths generated #410

Closed e-oz closed 10 years ago

e-oz commented 10 years ago

Please switch directory separator under Windows to usual slash (/), Windows can easy work with it. Today I reinstalled yeoman and generator-angular and after adding directive got
"<script src="scripts/directives\randomBackground.js"></script>"
which is pretty ugly.
If there is any option where I can turn off this behavior - please let me know.

pgilad commented 10 years ago

same problem here. i suspect it's a problem with path.join on windows: the controller was generated using yo angular-generator:collector Employee

and the path that was injected to index.html as the script src was: <script src="script\controllers\Employee.js"></script>

instead of: <script src="script/controllers/Employee.js"></script>

I think the problem is here: (script-base.js)

Generator.prototype.generateSourceAndTest = function (appTemplate, testTemplate, targetDirectory, skipAdd) {
  this.appTemplate(appTemplate, path.join('scripts', targetDirectory, this.name));
  this.testTemplate(testTemplate, path.join(targetDirectory, this.name));
  if (!skipAdd) {
    this.addScriptToIndex(path.join(targetDirectory, this.name));
  }
};
eddiemonge commented 10 years ago

Can you try this fix: https://github.com/eddiemonge/generator-angular/tree/webpath ? The fix specifically is: https://github.com/eddiemonge/generator-angular/blob/webpath/script-base.js#L100 Update that line in your yeoman and if its good, I'll merge it in

pgilad commented 10 years ago

Amazing... works wonders. You can merge the solution.