mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-25 02:21:52 -04:00
* refactor: use process-exists instead of is-running * fix(server): terminate the store server if graceful stop fails
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import tape = require('tape')
|
|
import promisifyTape from 'tape-promise'
|
|
const test = promisifyTape(tape)
|
|
import readPkg = require('read-pkg')
|
|
import {
|
|
prepare,
|
|
testDefaults,
|
|
execPnpm,
|
|
} from './utils'
|
|
import path = require('path')
|
|
import isWindows = require('is-windows')
|
|
import exists = require('path-exists')
|
|
|
|
test('uninstall package and remove from appropriate property', async function (t: tape.Test) {
|
|
const project = prepare(t)
|
|
await execPnpm('install', '--save-optional', 'is-positive@3.1.0')
|
|
|
|
// testing the CLI directly as there was an issue where `npm.config` started to set save = true by default
|
|
// npm@5 introduced --save-prod that bahaves the way --save worked in pre 5 versions
|
|
await execPnpm('uninstall', 'is-positive')
|
|
|
|
await project.storeHas('is-positive', '3.1.0')
|
|
|
|
await execPnpm('store', 'prune')
|
|
|
|
await project.storeHasNot('is-positive', '3.1.0')
|
|
|
|
await project.hasNot('is-positive')
|
|
|
|
const pkgJson = await readPkg()
|
|
t.equal(pkgJson.optionalDependencies, undefined, 'is-negative has been removed from optionalDependencies')
|
|
})
|
|
|
|
test('uninstall global package with its bin files', async (t: tape.Test) => {
|
|
prepare(t)
|
|
process.chdir('..')
|
|
|
|
const global = path.resolve('global')
|
|
const globalBin = isWindows() ? global : path.join(global, 'bin')
|
|
|
|
process.env.NPM_CONFIG_PREFIX = global
|
|
|
|
await execPnpm('install', '-g', 'sh-hello-world@1.0.1')
|
|
|
|
let stat = await exists(path.resolve(globalBin, 'sh-hello-world'))
|
|
t.ok(stat, 'sh-hello-world is in .bin')
|
|
|
|
await execPnpm('uninstall', '-g', 'sh-hello-world')
|
|
|
|
stat = await exists(path.resolve(globalBin, 'sh-hello-world'))
|
|
t.notOk(stat, 'sh-hello-world is removed from .bin')
|
|
})
|