Skip to content

[Bug]: VirtualFS.mapToBase incorrectly converts a full stop to an empty string #3136

Description

@merceyz

Self-service

  • I'd be willing to implement a fix

Describe the bug

VirtualFS.mapToBase incorrectly converts a full stop (.) to an empty string causing mkdirSync('.') to fail

const resolvedRoot = VirtualFS.resolveVirtual(this.baseFs.resolve(PortablePath.dot));
const resolvedP = VirtualFS.resolveVirtual(this.baseFs.resolve(p));
return ppath.relative(resolvedRoot, resolvedP);

Originally reported by @missing1984 on Discord with this repro https://github.com/missing1984/yarn2-webpack-ts

To reproduce

await expect(packageJsonAndInstall({})).resolves.toBeTruthy();

await expect(
  yarn(`node`, `-e`, `require('fs').mkdirSync('.', {recursive:true})`)
).resolves.not.toContain("no such file or directory");

Environment

System:
  OS: Windows 10 10.0.19042
  CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Binaries:
  Node: 16.4.2 - ~\AppData\Local\Temp\xfs-2ddaff2b\node.CMD
  Yarn: 3.0.0-rc.9.dev - ~\AppData\Local\Temp\xfs-2ddaff2b\yarn.CMD
  npm: 7.19.0 - C:\nodejs\npm.CMD

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreproducibleThis issue can be successfully reproduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions