Files
pnpm/exec/plugin-commands-script-runners/test/utils/index.ts
Jonathan Hefner 595ee11165 fix(dlx): ENOENT when symlink=false (#8732) (#8733)
Prior to this commit, if `symlink` was set to `false` (such as in an RC
file), `dlx` would throw `ENOENT` because it expected the
`node_modules/the-package` symlink to exist:

  ```console
  $ pnpm config get symlink
  false

  $ rm -rf ~/.cache/pnpm/

  $ pnpm dlx the-package
  Packages: +1
  +
  Progress: resolved 1, reused 1, downloaded 0, added 1, done
   ENOENT  ENOENT: no such file or directory, open '/home/${USER}/.cache/pnpm/dlx/.../
                                                    node_modules/the-package/package.json'
  ```

This commit filters the `symlink` option before installing the package,
allowing the symlink to be created, preventing the error.

Fixes #8732.
2024-11-06 10:44:10 +01:00

100 lines
2.2 KiB
TypeScript

import path from 'path'
import { tempDir } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
export const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
const tmp = tempDir()
export const DEFAULT_OPTS = {
argv: {
original: [],
},
bail: false,
bin: 'node_modules/.bin',
ca: undefined,
cacheDir: '../cache',
cert: undefined,
extraEnv: {},
cliOptions: {},
extraBinPaths: [],
fetchRetries: 2,
fetchRetryFactor: 90,
fetchRetryMaxtimeout: 90,
fetchRetryMintimeout: 10,
filter: [] as string[],
httpsProxy: undefined,
include: {
dependencies: true,
devDependencies: true,
optionalDependencies: true,
},
key: undefined,
linkWorkspacePackages: true,
localAddress: undefined,
lock: false,
lockStaleDuration: 90,
networkConcurrency: 16,
offline: false,
pending: false,
pnpmfile: './.pnpmfile.cjs',
pnpmHomeDir: '',
proxy: undefined,
rawConfig: { registry: REGISTRY_URL },
rawLocalConfig: {},
rootProjectManifestDir: '',
registries: { default: REGISTRY_URL },
registry: REGISTRY_URL,
sort: true,
storeDir: '../store',
strictSsl: false,
userAgent: 'pnpm',
useRunningStoreServer: false,
useStoreServer: false,
workspaceConcurrency: 4,
supportedArchitectures: {
os: ['current'],
cpu: ['current'],
libc: ['current'],
},
virtualStoreDirMaxLength: 120,
}
export const DLX_DEFAULT_OPTS = {
argv: {
original: [],
},
bail: false,
bin: 'node_modules/.bin',
cacheDir: path.join(tmp, 'cache'),
extraEnv: {},
extraBinPaths: [],
cliOptions: {},
dlxCacheMaxAge: Infinity,
include: {
dependencies: true,
devDependencies: true,
optionalDependencies: true,
},
linkWorkspacePackages: true,
lock: true,
pnpmfile: '.pnpmfile.cjs',
pnpmHomeDir: '',
rawConfig: { registry: REGISTRY_URL },
rawLocalConfig: { registry: REGISTRY_URL },
registries: {
default: REGISTRY_URL,
},
rootProjectManifestDir: '',
sort: true,
storeDir: path.join(tmp, 'store'),
symlink: true,
userConfig: {},
workspaceConcurrency: 1,
supportedArchitectures: {
os: ['current'],
cpu: ['current'],
libc: ['current'],
},
virtualStoreDirMaxLength: 120,
}