Files
pnpm/test/link.ts
zkochan b6fddf4234 feat: remove link-local
It is broken since the bit `Pure Store` and seems nobody even noticed.
This functionality should be implemented in a separate tool that
uses pnpm's API.

BREAKING CHANGE:

Remove the link-local option
2017-02-18 22:45:55 +02:00

65 lines
1.7 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)
await linkToGlobal(process.cwd(), testDefaults())
process.chdir(projectPath)
await linkFromGlobal(linkedPkgName, process.cwd(), testDefaults())
isExecutable(t, path.resolve('node_modules', '.bin', 'hello-world-js-bin'))
})