fix: run dlx in the root of Windows drive (#7264)

close #7263
This commit is contained in:
Nacho Aldama
2023-10-31 22:00:23 +01:00
committed by GitHub
parent cfc017ee38
commit 7d65d901ac
3 changed files with 20 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/plugin-commands-script-runners": patch
"@pnpm/store-path": patch
"pnpm": patch
---
Fix issue when trying to use `pnpm dlx` in the root of a Windows Drive [#7263](https://github.com/pnpm/pnpm/issues/7263).

View File

@@ -4,6 +4,8 @@ import { dlx } from '@pnpm/plugin-commands-script-runners'
import { prepareEmpty } from '@pnpm/prepare'
import { DLX_DEFAULT_OPTS as DEFAULT_OPTS } from './utils'
const testOnWindowsOnly = process.platform === 'win32' ? test : test.skip
test('dlx', async () => {
prepareEmpty()
@@ -121,3 +123,13 @@ test('dlx should return a non-zero exit code when the underlying script fails',
expect(exitCode).toBe(1)
})
testOnWindowsOnly('dlx should work when running in the root of a Windows Drive', async () => {
prepareEmpty()
await dlx.handler({
...DEFAULT_OPTS,
dir: 'C:\\',
storeDir: path.resolve('store'),
}, ['cowsay', 'hello'])
})

View File

@@ -40,7 +40,7 @@ export function getStorePath (
async function storePathRelativeToHome (pkgRoot: string, relStore: string, homedir: string) {
const tempFile = pathTemp(pkgRoot)
await fs.mkdir(path.dirname(tempFile), { recursive: true })
if (path.parse(pkgRoot).root !== pkgRoot) await fs.mkdir(path.dirname(tempFile), { recursive: true })
await touch(tempFile)
const storeInHomeDir = path.join(homedir, relStore, STORE_VERSION)
if (await canLinkToSubdir(tempFile, homedir)) {