Skip to content

Commit

Permalink
Look for packages below the cwd path (#89)
Browse files Browse the repository at this point in the history
We were previously using the binary path to determine the location
of installed packages (dependencies), but that's unreliable because
it can vary based on installation method, the $PATH, etc.

Instead, we trust our configured `cwd` to determine the package
installation root.
  • Loading branch information
jparise authored Mar 9, 2022
1 parent 0649dec commit 59a869a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/GraphQLSchemaLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public function getVersion() {
}

if (!empty($this->dependencyVersions)) {
$package_root = Filesystem::resolvePath($this->cwd, $this->getProjectRoot());

foreach ($this->dependencyVersions as $name => $required) {
$bin_root = dirname($this->getDefaultBinary());
list($err, $stdout, $stderr) = newv('ExecFuture', array('npm list -s --depth=0 --json'))
->setCWD($bin_root)
->setCWD($package_root)
->resolve();
$json = json_decode($stdout, true);
$dep_version = !empty($json) ? idxv($json, array('dependencies', $name, 'version')) : null;
Expand Down

0 comments on commit 59a869a

Please sign in to comment.