mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-07 05:32:52 -05:00
It is important to save the tarball URL as "relative-path" (without the leading '/'). Sometimes registries are located in a subdirectory of a website. For instance, https://mycompany.jfrog.io/mycompany/api/npm/npm-local/ So the tarball location should be relative to the directory, it is not an absolute-path reference. So we add @mycompany/mypackage/-/@mycompany/mypackage-2.0.0.tgz not /@mycompany/mypackage/-/@mycompany/mypackage-2.0.0.tgz PR #1834 close #1827
28 lines
988 B
TypeScript
28 lines
988 B
TypeScript
import { pkgSnapshotToResolution } from '@pnpm/lockfile-utils'
|
|
import test = require('tape')
|
|
|
|
test('pkgSnapshotToResolution()', (t) => {
|
|
t.deepEqual(pkgSnapshotToResolution('/foo/1.0.0', {
|
|
resolution: {
|
|
integrity: 'AAAA',
|
|
},
|
|
}, { default: 'https://registry.npmjs.org/' }), {
|
|
integrity: 'AAAA',
|
|
registry: 'https://registry.npmjs.org/',
|
|
tarball: 'https://registry.npmjs.org/foo/-/foo-1.0.0.tgz',
|
|
})
|
|
|
|
t.deepEqual(pkgSnapshotToResolution('/@mycompany/mypackage/2.0.0', {
|
|
resolution: {
|
|
integrity: 'AAAA',
|
|
tarball: '@mycompany/mypackage/-/@mycompany/mypackage-2.0.0.tgz',
|
|
},
|
|
}, { default: 'https://registry.npmjs.org/', '@mycompany': 'https://mycompany.jfrog.io/mycompany/api/npm/npm-local/' }), {
|
|
integrity: 'AAAA',
|
|
registry: 'https://mycompany.jfrog.io/mycompany/api/npm/npm-local/',
|
|
tarball: 'https://mycompany.jfrog.io/mycompany/api/npm/npm-local/@mycompany/mypackage/-/@mycompany/mypackage-2.0.0.tgz',
|
|
})
|
|
|
|
t.end()
|
|
})
|