Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('global link', async (t: tape.Test) => {
const project = prepare(t)
const projectPath = process.cwd()
const linkedPkgName = 'hello-world-js-bin'
const linkedPkgPath = path.resolve('..', linkedPkgName)
await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
process.chdir(linkedPkgPath)
const globalPrefix = path.resolve('..', 'global')
const globalBin = path.resolve('..', 'global', 'bin')
await linkToGlobal(process.cwd(), await testDefaults({globalPrefix, globalBin}))
await isExecutable(t, path.join(globalBin, 'hello-world-js-bin'))
// bins of dependencies should not be linked, see issue https://github.com/pnpm/pnpm/issues/905
t.notOk(await exists(path.join(globalBin, 'cowsay')), 'cowsay not linked')
t.notOk(await exists(path.join(globalBin, 'cowthink')), 'cowthink not linked')
process.chdir(projectPath)
await linkFromGlobal([linkedPkgName], process.cwd(), await testDefaults({globalPrefix}))
await project.isExecutable('.bin/hello-world-js-bin')
})
} else {
workspacePackages = {}
}
const store = await createOrConnectStoreControllerCached(storeControllerCache, opts)
const linkOpts = Object.assign(opts, {
storeController: store.ctrl,
storeDir: store.dir,
targetDependenciesField: getSaveType(opts),
workspacePackages,
})
// pnpm link
if (!input || !input.length) {
const { manifest, writeImporterManifest } = await tryReadImporterManifest(opts.globalDir!, opts)
const newManifest = await linkToGlobal(cwd, {
...linkOpts,
// A temporary workaround. global bin/prefix are always defined when --global is set
globalBin: linkOpts.globalBin!,
globalDir: linkOpts.globalDir!,
manifest: manifest || {},
})
await writeImporterManifest(newManifest)
return
}
const [pkgPaths, pkgNames] = R.partition((inp) => inp.startsWith('.'), input)
if (pkgNames.length) {
let globalPkgNames!: string[]
if (opts.workspaceDir) {
workspacePackagesArr = await findWorkspacePackages(opts.workspaceDir, opts)