diff options
author | 2023-02-09 00:37:14 +0200 | |
---|---|---|
committer | 2023-02-08 14:37:14 -0800 | |
commit | 18807cef03ac83a6a3dabded7a9735b87792f52e (patch) | |
tree | d40b8968840d16a7e1a96695b46e5415b3c4176a /test/bun.js/install/dummy.registry.ts | |
parent | cbc28afd51547f7a90161741cf826ee7f1485ae6 (diff) | |
download | bun-18807cef03ac83a6a3dabded7a9735b87792f52e.tar.gz bun-18807cef03ac83a6a3dabded7a9735b87792f52e.tar.zst bun-18807cef03ac83a6a3dabded7a9735b87792f52e.zip |
[install] assorted fixes & improvements (#2011)
- take `peerDependencies` into account during package placement
- do not recursively resolve `workspaces` (matches `npm`)
- link binaries to non-root packages correctly
- prune empty nodes during dependency tree construction
- support non-standard `workspace:` specifier
Diffstat (limited to 'test/bun.js/install/dummy.registry.ts')
-rw-r--r-- | test/bun.js/install/dummy.registry.ts | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/test/bun.js/install/dummy.registry.ts b/test/bun.js/install/dummy.registry.ts index 9738591cc..179231ed1 100644 --- a/test/bun.js/install/dummy.registry.ts +++ b/test/bun.js/install/dummy.registry.ts @@ -1,14 +1,13 @@ import { file } from "bun"; import { expect } from "bun:test"; -import { realpathSync } from "fs"; -import { mkdtemp, readdir, rm } from "fs/promises"; +import { mkdtemp, readdir, realpath, rm } from "fs/promises"; import { tmpdir } from "os"; import { basename, join } from "path"; let handler, server; export let package_dir, requested, root_url; -export function dummyRegistry(urls, version = "0.0.2", props = {}) { +export function dummyRegistry(urls, info: object = { "0.0.2": {} }) { return async request => { urls.push(request.url); expect(request.method).toBe("GET"); @@ -21,19 +20,22 @@ export function dummyRegistry(urls, version = "0.0.2", props = {}) { expect(request.headers.get("npm-auth-type")).toBe(null); expect(await request.text()).toBe(""); const name = request.url.slice(request.url.lastIndexOf("/") + 1); + const versions = {}; + let version; + for (version in info) { + versions[version] = { + name, + version, + dist: { + tarball: `${request.url}-${info[version].as ?? version}.tgz`, + }, + ...info[version], + }; + } return new Response( JSON.stringify({ name, - versions: { - [version]: { - name, - version, - dist: { - tarball: `${request.url}.tgz`, - }, - ...props, - }, - }, + versions, "dist-tags": { latest: version, }, @@ -74,7 +76,7 @@ export function dummyAfterAll() { export async function dummyBeforeEach() { resetHanlder(); requested = 0; - package_dir = realpathSync(await mkdtemp(join(tmpdir(), "bun-install.test"))); + package_dir = await mkdtemp(join(await realpath(tmpdir()), "bun-install.test")); } export async function dummyAfterEach() { |