Skip to content
Myr

Merge pull request #935 from MarshallOfSound/fix-deep-sym-link-resolution

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tomoaki Abe · committed by GitHub · parents 291fc04, 994d24d · Browse files · 6 files+27 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • fix: resolve symbolic links completely when hunting for subcommands

Diff stats

6 files+27 added−7 removed

  • tests:+23 added−0 removed
  • other:+4 added−7 removed

6 files+27 added−7 removed

added:test/fixtures/another-dir/pm+1 added
1../other-dir/pm
added:test/fixtures/other-dir/pm+1 added
1../pm
modified:test/test.command.executableSubcommand.js+7 added
modified:test/test.command.executableSubcommandAlias.js+7 added
modified:test/test.command.executableSubcommandDefault.js+7 added
modified:index.js+4 added-7 removed
525 unmodified lines
526 var bin = basename(f, path.extname(f)) + '-' + args[0];527528 // In case of globally installed, get the base dir where executable529 // subcommand file should be located at530 var baseDir,531 link = fs.lstatSync(f).isSymbolicLink() ? fs.readlinkSync(f) : f;530 var baseDir;531533 // when symbolink is relative path534 if (link !== f && link.charAt(0) !== '/') {535 link = path.join(dirname(f), link);536 }537 baseDir = dirname(link);532 var resolvedLink = fs.realpathSync(f);533534 baseDir = dirname(resolvedLink);535536 // prefer local `./<bin>` to bin in the $PATH537 var localBin = path.join(baseDir, bin);538539 // whether bin file is a js script with explicit `.js` or `.ts` extension
685 unmodified lines