meanjs / generator-meanjs

MEAN.JS Official Yeoman Generator
http://meanjs.org/
473 stars 177 forks source link

Project fails to startup when naming a crud module as a plural noun that doesn't end in 's'. #234

Open donohutcheon opened 8 years ago

donohutcheon commented 8 years ago

The bug is reproducible by following the following Youtube video MeanJS - MEAN stack Yeoman Generator Tutorial from 3:47 up to 5:54.

The problem occurs because the crud-module/templates/tests/server/_.server.routes.tests.js file refers to a variable named <%= camelizedPluralName %>GetRes on line 89 but in the function definition on line 82 the argument is named : camelizedSingularName %>sGetErr. For most English nouns this problem will go undetected, however in the case of Superheroes (and other plural nouns that don't end in 's') the test defines a function argument of SuperherosGetRes (line 82) but on line 89 refers to the correct plural variable name: SuperheroesGetRes.

The result is that the test fails and gulp does not initialise the application when executed using gulp:

$ gulp
[14:55:07] Using gulpfile ~/dev/nodejs/xmen/gulpfile.js
[14:55:07] Starting 'default'...
[14:55:07] Starting 'env:dev'...
[14:55:07] Finished 'env:dev' after 78 μs
[14:55:07] Starting 'lint'...
[14:55:07] Starting 'less'...
[14:55:08] Finished 'less' after 313 ms
[14:55:08] Starting 'sass'...
[14:55:08] Finished 'sass' after 23 ms
[14:55:08] Starting 'csslint'...
[14:55:08] Starting 'eslint'...
[14:55:08] Starting 'jshint'...
[14:55:08] Finished 'csslint' after 542 ms
modules/superheroes/tests/server/superhero.server.routes.tests.js: line 89, col 35, 'superheroesGetRes' is not defined.

1 error
[14:55:12] Finished 'eslint' after 3.86 s
[14:55:12] 'jshint' errored after 3.72 s
[14:55:12] Error in plugin 'gulp-jshint'
Message:
    JSHint failed for: modules/superheroes/tests/server/superhero.server.routes.tests.js
[14:55:12] 'default' errored after 4.22 s
[14:55:12] Error in plugin 'run-sequence(jshint)'
Message:
    jshint stream
[14:55:12] 'lint' errored after 4.22 s
[14:55:12] Error in plugin 'run-sequence(default)'
Message:
    default callback
[14:55:12] 'lint' errored after 4.22 s
[14:55:12] Error in plugin 'run-sequence(jshint)'
Message:
    jshint stream

Obviously there are other scenarios where the inflections module will fail to match the module name to the appropriate noun / plural noun, for example formulae becomes formulaes. For this specific scenario the actual template code is inconsistent and should be fixed.

donohutcheon commented 8 years ago

I'd like to submit a patch for this bug that will correct the problem. _.server.routes.tests.js.zip

codydaig commented 8 years ago

@donohutcheon Can you submit a PR for it?

donohutcheon commented 7 years ago

No problem. I'm new to GitHub but keen to help. What's the protocol? Do I need permissions to create a new branch?

codydaig commented 7 years ago

You fork the repo, create a branch on your repo, make your changes and commit, then create a PR from your branch on your fork to the master branch of this repo as the base.