Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/utils/installed-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ const installedDeep = async (npm) => {

const res = new Set()
const gArb = new Arborist({
...npm.flatOptions,
global: true,
path: resolve(npm.globalDir, '..'),
workspacesEnabled,
// Completion only lists names; never execute a project .npm-extension.
ignoreExtension: true,
})
const gTree = await gArb.loadActual({ global: true })

Expand All @@ -32,7 +35,13 @@ const installedDeep = async (npm) => {
}

if (!global) {
const arb = new Arborist({ global: false, path: prefix, workspacesEnabled })
const arb = new Arborist({
...npm.flatOptions,
global: false,
path: prefix,
workspacesEnabled,
ignoreExtension: true,
})
const tree = await arb.loadActual()
for (const node of getValues(tree)) {
res.add(node.name)
Expand Down
22 changes: 22 additions & 0 deletions test/lib/utils/installed-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,28 @@ t.test('limit depth', async t => {
)
})

t.test('does not execute .npm-extension during completion inventory', async t => {
const mock = await mockNpm(t, {
prefixDir: {
'package.json': JSON.stringify({
name: 'ext-poc',
version: '1.0.0',
}),
'.npm-extension.mjs': [
"throw new Error('npm-extension should not run during completion')",
'export const transformManifest = (pkg) => pkg',
].join('\n'),
},
globalPrefixDir: globalFixture,
config: {
depth: Infinity,
},
})

const res = await installedDeep(mock.npm)
t.ok(Array.isArray(res), 'inventory still returns a list')
})

t.test('limit depth as global', async t => {
const res = await mockDeep(t, { depth: 0, global: true })
t.same(
Expand Down