acrazing/dpdm

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

jayu opened this issue · 2 comments

jayu commented

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

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 commented

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