Skip to content

Commit 875c165

Browse files
committed
fix: assert existance of package-json in npx cache
1 parent 7350e96 commit 875c165

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

workspaces/libnpmexec/test/registry.js

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { resolve } = require('node:path')
22
const t = require('tap')
33
const { setup, createPkg, merge } = require('./fixtures/setup.js')
44
const crypto = require('node:crypto')
5+
const { existsSync } = require('node:fs')
56

67
t.test('run from registry - no local packages', async t => {
78
const { fixtures, package } = createPkg({ versions: ['2.0.0'] })
@@ -301,6 +302,11 @@ t.test('npx tree triggers manifest fetch when local version does satisfy range u
301302
t.test('override save to true when installing to npx cache', async t => {
302303
const { fixtures, package } = createPkg({ versions: ['2.0.0'] })
303304

305+
const hash = crypto.createHash('sha512')
306+
.update('@npmcli/create-index')
307+
.digest('hex')
308+
.slice(0, 16)
309+
304310
const { exec, path, registry, readOutput } = setup(t, {
305311
testdir: merge(fixtures, {
306312
global: {},
@@ -315,6 +321,9 @@ t.test('override save to true when installing to npx cache', async t => {
315321
save: false,
316322
})
317323

324+
const packageJsonPath = resolve(path, 'npxCache', hash, 'package.json')
325+
t.ok(existsSync(packageJsonPath), 'package.json should exist at global path')
326+
318327
t.match(await readOutput('@npmcli-create-index'), {
319328
value: 'packages-2.0.0',
320329
})

0 commit comments

Comments
 (0)