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

Abstract file system. Wrong root passed to resolve #412

Closed
floofnoodlecode opened this issue Oct 14, 2021 · 2 comments
Closed

Abstract file system. Wrong root passed to resolve #412

floofnoodlecode opened this issue Oct 14, 2021 · 2 comments

Comments

@floofnoodlecode
Copy link

I am using liquidjs in a react app, so it is running in the browser. I need to customize how the paths are interpreted, so I provided an FS object like in the documentation. I also need to change the default root.

The issue is that the root that gets passed to resolve(root, file, ext) is not the one that I'm providing when creating the Liquid instance. I end up with a URL as root. I spent some time debugging this. Take this code for example:

const engine = new Liquid({
  fs: some_fs_implementation,
  root: '~',
})

When creating a new Liquid object, the options are first normalized using src/liquid-options.ts: normalize(), which calls normalizeDirectoryList(options.root). This function returns:

  return list.map(str => fs.resolve(str, '.', '')).map(str => str[str.length - 1] !== '/' ? str + '/' : str)

However, the fs.resolve() that this function uses is not the fs that I passed in the options. Not only that but it also adds other characters after the root I provided.

I don't understand why that return is the way it is, but it seems to behave in a really unintuitive way.

@harttle
Copy link
Owner

harttle commented Oct 15, 2021

You're right. Both of the two ideas.

@harttle harttle added the bug label Oct 15, 2021
github-actions bot pushed a commit that referenced this issue Oct 16, 2021
## [9.28.1](v9.28.0...v9.28.1) (2021-10-16)

### Bug Fixes

* hardcoded '/' in normalized `options.fs`, fixes [#412](#412), [#408](#408) ([9cfa43b](9cfa43b))
@github-actions
Copy link

🎉 This issue has been resolved in version 9.28.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants