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

docmaker fails to correctly reset current directory after loading data files #31

Open
raqbit opened this issue Sep 21, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@raqbit
Copy link
Contributor

raqbit commented Sep 21, 2020

Describe the bug

When processing data files, Docmaker tries to change the working directory to the project directory. This is done to allow dynamic (js) data files to be able to simply open files (fs.readFile etc.) relative to the project directory.

https://github.com/BlameButton/docmaker/blob/8516b9161278e85c053fd81c10b2f1c5c7428f32/src/data.ts#L45-L46

After processing all data files Docmaker tries to reset the path back to its original setting, but it appears getCwd() does not return a full path but a relative path (e.g. foo instead of /home/<user>/Documents/foo) which makes the call to chdir fail.

https://github.com/BlameButton/docmaker/blob/8516b9161278e85c053fd81c10b2f1c5c7428f32/src/data.ts#L52

✖  error     Error: ENOENT: no such file or directory, chdir '/path/to/foo' -> 'foo' 

To Reproduce

Steps to reproduce the behavior:

  1. Run docmaker with the configuration below
  2. See error

Expected behavior

It should correctly reset the current directory after loading all data files.

Configuration

docmaker.yaml:

layout: "layout.html"
pages:
  - "*.md"
data:
  - "data.js"

page.md:

# Test
- This is a test

layout.html:

{{ content }}

data.js:

return { foo: "bar" };

Desktop (please complete the following information)

  • OS / version: Ubuntu 20.04
  • Docmaker version: 0.1.4
@raqbit raqbit added the bug Something isn't working label Sep 21, 2020
@bram-pkg
Copy link
Member

Would adding a basename call help?

@raqbit
Copy link
Contributor Author

raqbit commented Sep 24, 2020

uhh no, I don't think so. Somehow getCwd() is returning a relative path, we should probably convert that to a absolute path first

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

2 participants