mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
5
.changeset/hot-berries-invent.md
Normal file
5
.changeset/hot-berries-invent.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/read-modules-dir": patch
|
||||
---
|
||||
|
||||
Ignore files in node_modules.
|
||||
@@ -16,18 +16,18 @@ async function _readModulesDir (
|
||||
) {
|
||||
let pkgNames: string[] = []
|
||||
const parentDir = scope ? path.join(modulesDir, scope) : modulesDir
|
||||
for (const dir of await fs.readdir(parentDir)) {
|
||||
if (dir[0] === '.') continue
|
||||
for (const dir of await fs.readdir(parentDir, { withFileTypes: true })) {
|
||||
if (dir.isFile() || dir.name[0] === '.') continue
|
||||
|
||||
if (!scope && dir[0] === '@') {
|
||||
if (!scope && dir.name[0] === '@') {
|
||||
pkgNames = [
|
||||
...pkgNames,
|
||||
...await _readModulesDir(modulesDir, dir),
|
||||
...await _readModulesDir(modulesDir, dir.name),
|
||||
]
|
||||
continue
|
||||
}
|
||||
|
||||
const pkgName = scope ? `${scope}/${dir}` : dir
|
||||
const pkgName = scope ? `${scope}/${dir.name}` : dir.name
|
||||
pkgNames.push(pkgName)
|
||||
}
|
||||
return pkgNames
|
||||
|
||||
@@ -1148,3 +1148,25 @@ test('installing a package that has a manifest with byte order mark (BOM)', asyn
|
||||
|
||||
await project.has('paralleljs')
|
||||
})
|
||||
|
||||
test('ignore files in node_modules', async (t: tape.Test) => {
|
||||
const project = prepareEmpty(t)
|
||||
const reporter = sinon.spy()
|
||||
|
||||
await fs.mkdir('node_modules')
|
||||
await fs.writeFile('node_modules/foo', 'x', 'utf8')
|
||||
|
||||
await addDependenciesToPackage(
|
||||
{
|
||||
name: 'project',
|
||||
version: '0.0.0',
|
||||
},
|
||||
['lodash@4.0.0'],
|
||||
await testDefaults({ fastUnpack: false, reporter })
|
||||
)
|
||||
|
||||
const m = project.requireModule('lodash')
|
||||
t.ok(typeof m === 'function', '_ is available')
|
||||
t.ok(typeof m.clone === 'function', '_.clone is available')
|
||||
t.equal(await fs.readFile('node_modules/foo', 'utf8'), 'x')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user