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

When no name is specified in mdx file, it throws Cannot read property 'name' of undefined #59

Closed
fc opened this issue Jun 18, 2018 · 12 comments
Labels
bug Something isn't working

Comments

@fc
Copy link

fc commented Jun 18, 2018

Bug Report

To Reproduce

Create an MDX file with no name specified.
It will generate the error:

$ docz dev
TypeError: Cannot read property 'name' of undefined
    at new Entry (.../frontend/node_modules/docz-core/dist/index.js:1:5189)
    at Promise.all.s.filter.map (.../frontend/node_modules/docz-core/dist/index.js:1:7654)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

Expected behavior

Provide a helpful error message that $path/to/file.mdx does not contain a name.

It probably occurs at this line but couldn't find out how to run docz without using the dist version to validate:
https://github.com/pedronauck/docz/blob/master/packages/docz-core/src/Entry.ts#L98

@vivek12345
Copy link
Contributor

@pedronauck I would like to take this up.The solution I am thinking here is throwing an error with the message of $path/to/file.mdx does not contain a name.

@vivek12345
Copy link
Contributor

vivek12345 commented Jun 26, 2018

@pedronauck While trying to do a yarn commit I am facing this error

stderr: 'ERROR: Task not found: "/Users/viveknayyar/vivek/docz/packages/docz-core/src/Entry.ts"
✖ "yarn packages:fix" found some errors. Please fix them and try committing again.
$ lerna run fix /Users/viveknayyar/vivek/docz/packages/docz-core/src/Entry.ts

@pedronauck pedronauck added bug Something isn't working and removed enhancement labels Jun 27, 2018
@vivek12345
Copy link
Contributor

@pedronauck Can you help here in this yarn commit issue that I am facing.

@pedronauck
Copy link
Member

Do you trying to build packages to make some pull request @vivek12345? Which version of node you're using?

@vivek12345
Copy link
Contributor

vivek12345 commented Jun 27, 2018

Node version is v9.0.0 @pedronauck
and this is the change that I am trying to commit

if (!parsed) {
   throw new Error(`${filepath} does not contain a name`)
}

@vivek12345
Copy link
Contributor

@pedronauck any suggestions as to what I can do to commit my change and make a PR for the same.

@marceloavf
Copy link
Contributor

what commands are you using to build and then commit @vivek12345 ?

@vivek12345
Copy link
Contributor

vivek12345 commented Jun 28, 2018

@marceloavf I did those above mentioned changes inside docz-core/src/Entry.ts
After that did a yarn build in docz-core folder.

Finally git add and yarn commit

I see this error all the time

ERROR: Task not found: "/Users/viveknayyar/vivek/docz/packages/docz-core/src/Entry.ts"

@marceloavf
Copy link
Contributor

@vivek12345 Seems to be some issue with this path.

For now, try to commit normally with git commit -m "fix(docz-core): throw error in no parsed file" and see if it works.

If you could please say your Operational System too, should help us find what is happening.
Thank you

@vivek12345
Copy link
Contributor

Sure I will try as you suggested.
I am working from my MacBook Pro macOs High Sierra

@vivek12345
Copy link
Contributor

Thank you @marceloavf for your help. I have raised a PR for the same.

@pedronauck
Copy link
Member

pedronauck commented Jun 30, 2018

🎉  Fixed and released in the new v0.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants