mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 13:02:03 -04:00
fix(unlink): no unnecessary warning about scoped packages
This commit is contained in:
@@ -83,16 +83,19 @@ async function getExternalPackages (
|
||||
scope?: string
|
||||
): Promise<string[]> {
|
||||
let externalLinks: string[] = []
|
||||
for (const dir of await fs.readdir(modules)) {
|
||||
const parentDir = scope ? path.join(modules, scope) : modules
|
||||
for (const dir of await fs.readdir(parentDir)) {
|
||||
if (dir[0] === '.') continue
|
||||
|
||||
if (!scope && dir[0] === '@') {
|
||||
externalLinks = externalLinks.concat(await getExternalPackages(path.join(modules, dir), store, dir))
|
||||
externalLinks = externalLinks.concat(await getExternalPackages(modules, store, dir))
|
||||
continue
|
||||
}
|
||||
|
||||
if (await isExternalLink(store, modules, dir)) {
|
||||
externalLinks.push(scope ? `${scope}/${dir}` : dir)
|
||||
const pkgName = scope ? `${scope}/${dir}` : dir
|
||||
|
||||
if (await isExternalLink(store, modules, pkgName)) {
|
||||
externalLinks.push(pkgName)
|
||||
}
|
||||
}
|
||||
return externalLinks
|
||||
|
||||
@@ -117,6 +117,20 @@ test('unlink all packages', async (t: tape.Test) => {
|
||||
t.equal(typeof project.requireModule('@zkochan/logger'), 'object', '@zkochan/logger installed after unlinked')
|
||||
})
|
||||
|
||||
test("don't warn about scoped packages when running unlink w/o params", async (t: tape.Test) => {
|
||||
const project = prepare(t)
|
||||
|
||||
await installPkgs(['@zkochan/logger'], testDefaults())
|
||||
|
||||
const reporter = sinon.spy()
|
||||
await unlink(testDefaults({reporter}))
|
||||
|
||||
t.notOk(reporter.calledWithMatch({
|
||||
level: 'warn',
|
||||
message: '@zkochan/logger is not an external link',
|
||||
}), 'not reported warning')
|
||||
})
|
||||
|
||||
test("don't unlink package that is not a link", async (t: tape.Test) => {
|
||||
const project = prepare(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user