pnpm / cmd-shim

The cmd-shim used in pnpm
Other
14 stars 11 forks source link

fix absolute path #16

Closed oneplusdash closed 5 years ago

oneplusdash commented 5 years ago

Relative path cannot be used under different partitions under windows

Js-Brecht commented 5 years ago

This looks like it would fix the issue I'd been having with running pnpm on another partition. All of the cmd shims being generated in local project directories and the global directory were malformed. Thought I would let you know that the issue was also appearing in the Pwsh shims.

What I wound up doing as a workaround was resolving the real path before trying to find the relative path, and it's been working for me.


....
function generateCmdShim (src, to, opts) {
  // `shTarget` is not used to generate the content.
  const shTarget = path.relative(fs.realpathSync(path.dirname(to)), src)
....
function generatePwshShim (src, to, opts) {
  let shTarget = path.relative(fs.realpathSync(path.dirname(to)), src)
....
oneplusdash commented 5 years ago

generatePwshShim It should also be modified. In the author's version, the following situations can lead to problems:path.relative('C:/a', 'D:/a'))output: ../../D:/a

ExE-Boss commented 5 years ago

That returns 'D:\\a' for me.

zkochan commented 5 years ago

Please also cover it with tests

cspotcode commented 5 years ago

I'm looking into test coverage for this. Rather than create a second drive on Windows, I'm gonna see if we can use mock-fs.

zkochan commented 5 years ago

There's a new PR for this #18