mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-25 10:31:55 -04:00
* fix: global installation always works now Close #711 * refactor: avoid using `read-pkg-up` BREAKING CHANGE: API should be called in the folder that has a package.json file. pnpm won't search up for a package.json file. Close #67 * docs(API): update * refactor: write-pkg created dir on its own * refactor: rename `globalDir` to `globalPrefix` * feat: saving the global package in <global prefix>/pnpm-global
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import tape = require('tape')
|
|
import promisifyTape from 'tape-promise'
|
|
const test = promisifyTape(tape)
|
|
import path = require('path')
|
|
import {
|
|
prepare,
|
|
isExecutable,
|
|
pathToLocalPkg,
|
|
testDefaults,
|
|
} from './utils'
|
|
import thenify = require('thenify')
|
|
import ncpCB = require('ncp')
|
|
const ncp = thenify(ncpCB.ncp)
|
|
import {
|
|
link,
|
|
linkToGlobal,
|
|
linkFromGlobal,
|
|
installPkgs
|
|
} from '../src'
|
|
|
|
test('relative link', async function (t) {
|
|
prepare(t)
|
|
|
|
const linkedPkgName = 'hello-world-js-bin'
|
|
const linkedPkgPath = path.resolve('..', linkedPkgName)
|
|
|
|
await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
|
|
await link(`../${linkedPkgName}`, process.cwd(), testDefaults())
|
|
|
|
isExecutable(t, path.resolve('node_modules', '.bin', 'hello-world-js-bin'))
|
|
})
|
|
|
|
test('relative link is not rewritten by install', async function (t) {
|
|
const project = prepare(t)
|
|
|
|
const linkedPkgName = 'hello-world-js-bin'
|
|
const linkedPkgPath = path.resolve('..', linkedPkgName)
|
|
|
|
await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
|
|
await link(`../${linkedPkgName}`, process.cwd(), testDefaults())
|
|
|
|
await installPkgs(['hello-world-js-bin'], testDefaults())
|
|
|
|
t.ok(project.requireModule('hello-world-js-bin/package.json').isLocal)
|
|
})
|
|
|
|
test('global link', async function (t) {
|
|
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')
|
|
await linkToGlobal(process.cwd(), Object.assign(testDefaults(), {globalPrefix}))
|
|
|
|
process.chdir(projectPath)
|
|
|
|
await linkFromGlobal(linkedPkgName, process.cwd(), Object.assign(testDefaults(), {globalPrefix}))
|
|
|
|
isExecutable(t, path.resolve('node_modules', '.bin', 'hello-world-js-bin'))
|
|
})
|