mcfly-io / generator-mcfly

A Yeoman generator for scaffolding an application using angular, browserify, ionic and famous

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module does not exist while creating components for modules with snake-case

jagged3dge opened this issue · comments

I am using snake-case names for my project. I have created a module with the name uiAutofill to contain a directive called autoFill. So, the module folder is named ui-autofill. However, when I try to generate the directive, it keeps saying Error: The module name 'ui-autofill' does not exist.

This happens even when I'm not providing a module name upfront while initiating the directive sub-generator.

Steps to reproduce:

  1. Create a module: yo mcfly:module uiAutofill
  2. Try to create a directive with either of these commands:
  • yo mcfly:directive uiAutofill autoFill --compile=false or
  • yo mcfly:directive --compile=false then choose ui-autofill when prompted to select module

I'm using the latest generator version 1.7.4.

Here's the auto-generated yo-rc.json file for my project:

{
  "generator-mcfly": {
    "filenameCase": "snake",
    "filenameSuffix": true,
    "appname": "ngMcflyLazyTest",
    "clientFolder": "client",
    "ionic": false,
    "famous": false,
    "ngCordova": false,
    "fontawesome": false,
    "bootstrap": false,
    "material": false
  }
}

I'll check this out in a little bit...

Thanks for the quick reply :)

Here's a screenshot of the commands I've used:
mcfly-modulenotfounderror

@jagged3dge, I can reproduce the issue and I'm diagnosing it now.

My first guess is the problem comes from the way the generator figures out which modules exist.

Yup that was it. I'm fixing it now.

It looks like the problem was coming from the fact that the app was checking the existing module folder names that get stuck in this.clientModules (and are casified according to the preferences in .yo-rc.json) for the requested this.modulename (which is always camelized, since this is the name used for angular).

An example is here: https://github.com/mcfly-io/generator-mcfly/blob/master/class/component.js#L123

I've changed the places where this check occurs to check this.clientModules for this.moduleFolder, which is the correctly casified folder name.

Thanks for the fix! ^_^ Should I wait for the next release or install from the master branch?

We're still reviewing/testing the PR to make sure it doesn't break anything, so I haven't merged the master yet. I'd expect it tomorrow or Thursday.

If you want it sooner, I'd just monkey-patch the version installed in your global node_modules folder. I think this is in your %AppData%\npm\node_modules folder on windows.

Implement the patch based on this commit: 9181611

Monkey-patching for the win! Works smoothly. Thanks again 👍