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

Cannot get dependencies using different context than process.cwd() #22

Open
jayu opened this issue Aug 6, 2022 · 2 comments
Open

Cannot get dependencies using different context than process.cwd() #22

jayu opened this issue Aug 6, 2022 · 2 comments

Comments

@jayu
Copy link

jayu commented Aug 6, 2022

Thank you for this lib!

I've noticed a bug around context option. Searching for dependencies using custom context does not work as expected.

Perhaps it's because you use const currentDirectory = process.cwd(); instead of const currentDirectory = options.context in

const currentDirectory = process.cwd();

To workaround this I had to do the following, but I would rather not :D

// dpdm does not support custom search directory :/
const oldProcessCwd = process.cwd
process.cwd = () => cwd

deps = cleanupDpdmDeps(
  await parseDependencyTree(entryPoints, {
    context: cwd // does not work as expected
  })
)

process.cwd = oldProcessCwd

https://github.com/jayu/rev-dep/blob/master/src/lib/getDepsTree.ts#L15-L25

@acrazing
Copy link
Owner

acrazing commented Aug 7, 2022

The context option is only used to shorten the path, not to specify the current working directory. It requires an additional option to configure to implement this feature.

@jayu
Copy link
Author

jayu commented Aug 16, 2022

Gotcha! How about adding an option to support different working directories?

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

No branches or pull requests

2 participants