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

prevent to overwrite handlers when handler is created already #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kangchals
Copy link

A result of fs.readdirSync(dir) is important because it could create error when the order of directory name precede filename.

for example, let's assume that there is two files.
handlers/users.js
handlers/users/{userId}.js
Normally the result of fs.readdirSync(dir) will be ['users.js', 'users']. it works fine.
However, when the result of fs.readdirSync(dir) is [ 'users', 'users.js']. it makes error. it will overwrite users.js's handler.

I faced this situation when I tried to use pkg(https://github.com/zeit/pkg) for my project using swaggerize-hapi

I read the api document for fs.readdirSync, I cannot found the order of the result fixed.

I think the code requesting pull request prevent that kind of possible error situation.

Thanks!

@kangchals
Copy link
Author

Object.assign is not supported the node version is below than 4.....

I found ponyfill for the Object.assign 'https://www.npmjs.com/package/object-assign'

Do you want to apply the ponyfill and pull request again?

Let me know~

@pmarino90
Copy link

Hi, I arrived at the same issue when using pkg. I fixed with Object.assign too. Is there any issue for keeping this open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants