Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added generator for middleware #261

Merged
merged 4 commits into from
Aug 4, 2016
Merged

Conversation

adampash
Copy link
Contributor

@adampash adampash commented Aug 3, 2016

Addresses #256

@zacharygolba
Copy link
Contributor

I'm getting the following error due to the file path for the newly created middleware being invalid:

{ Error: ENOENT: no such file or directory, open '/Users/zacharygolba/Desktop/blog/app/middlewares/set-cors-headers.js'
    at Error (native)
  cause:
   { Error: ENOENT: no such file or directory, open '/Users/zacharygolba/Desktop/blog/app/middlewares/set-cors-headers.js'
       at Error (native)
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/Users/zacharygolba/Desktop/blog/app/middlewares/set-cors-headers.js' },
  isOperational: true,
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/zacharygolba/Desktop/blog/app/middlewares/set-cors-headers.js' }

I'm guessing this is due to the type parameter being pluralized when it should within the generate command handler.


case 'middleware':
data = middlewareTemplate(name);
break;
}

if (type === 'model') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh here's the culprit. We should probably replace that with a regexp /^(model|middleware)$/.test(type).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind that's the name haha. I got excited.

@zacharygolba
Copy link
Contributor

Ahh I figured out why I was getting that error. I had to remove the locally installed Lux to get the globally npm linked cli rather than the locally installed one. This is working as expect 👍. Disregard my comments.

@adampash
Copy link
Contributor Author

adampash commented Aug 3, 2016

Ha great! Yeah I was wondering what was going wrong! It does actually give you a sense of some polishing that the generator could use, though — you'll get the same error anytime you misspell a generator.

Instead, if it doesn't match anything, you might consider, at some point, giving suggestions for what generators are available.

@zacharygolba
Copy link
Contributor

Instead, if it doesn't match anything, you might consider, at some point, giving suggestions for what generators are available.

That's an awesome idea! Would you mind creating an issue for that with a feature label?

@zacharygolba
Copy link
Contributor

Added the needs-update label to address lux d middleware <name> command as discussed on Flowdock and in #262.

@adampash
Copy link
Contributor Author

adampash commented Aug 3, 2016

Added lux d middleware <name> in latest commit.

@zacharygolba
Copy link
Contributor

👍 Works great!

@adampash adampash merged commit 94abf14 into master Aug 4, 2016
@zacharygolba zacharygolba deleted the feat-add-middleware-generator branch August 5, 2016 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants