mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-04 23:34:58 -04:00
@@ -1,6 +1,7 @@
|
||||
import logger from 'pnpm-logger'
|
||||
import path = require('path')
|
||||
import isInnerLink = require('is-inner-link')
|
||||
import rimraf = require('rimraf-then')
|
||||
|
||||
export default async function safeIsInnerLink (modules: string, depName: string) {
|
||||
try {
|
||||
@@ -12,6 +13,9 @@ export default async function safeIsInnerLink (modules: string, depName: string)
|
||||
return false
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return true
|
||||
throw err
|
||||
|
||||
logger.warn(`Removing ${depName} that was installed by a different package manager`)
|
||||
await rimraf(path.join(modules, depName))
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
14
test/cli.ts
14
test/cli.ts
@@ -2,7 +2,7 @@ import path = require('path')
|
||||
import tape = require('tape')
|
||||
import promisifyTape from 'tape-promise'
|
||||
const test = promisifyTape(tape)
|
||||
import spawn = require('cross-spawn')
|
||||
import execa = require('execa')
|
||||
import exists = require('path-exists')
|
||||
import mkdirp = require('mkdirp-promise')
|
||||
import {
|
||||
@@ -33,6 +33,18 @@ test('installs in the folder where the package.json file is', async function (t)
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
})
|
||||
|
||||
test('rewrites node_modules created by npm', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
await execa('npm', ['install', 'rimraf@2.5.1', '--save'])
|
||||
|
||||
await execPnpm('install')
|
||||
|
||||
const rimraf = project.requireModule('rimraf')
|
||||
t.ok(typeof rimraf === 'function', 'rimraf() is available')
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
})
|
||||
|
||||
test('update', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user