Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Npm {
}

// Check dev engines if needed
if (commandInstance.checkDevEngines && !this.global) {
if (Command.checkDevEngines && !this.global) {
await commandInstance.checkDevEngines()
}

Expand Down
21 changes: 21 additions & 0 deletions test/lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,27 @@ t.test('exec edge cases', async t => {
})
})

t.test('devEngines', async t => {
const prefixDir = {
'package.json': JSON.stringify({
name: 'test-package',
version: '1.0.0',
devEngines: { packageManager: { name: 'pnpm' } },
}),
}

t.test('is not checked by a command that does not opt in', async t => {
const { npm, joinedFullOutput } = await loadMockNpm(t, { prefixDir })
await npm.exec('prefix', [])
t.notMatch(joinedFullOutput(), 'EBADDEVENGINES')
})

t.test('is checked by a command that opts in', async t => {
const { npm } = await loadMockNpm(t, { prefixDir })
await t.rejects(npm.exec('run', []), { code: 'EBADDEVENGINES' })
})
})

t.test('usage', async t => {
t.test('with browser', async t => {
const { npm } = await loadMockNpm(t, { globals: { process: { platform: 'posix' } } })
Expand Down
Loading