|
1 | 1 | import { deepEqual } from "node:assert/strict"; |
| 2 | +import { spawnSync } from "node:child_process"; |
2 | 3 | import { afterEach, describe, it } from "node:test"; |
3 | | -import { URL } from "node:url"; |
4 | 4 | import { updatePackageManifest as updatePackageManifestActual } from "../../scripts/configure.mjs"; |
5 | | -import { readJSONFile } from "../../scripts/helpers.js"; |
6 | | -import type { Manifest } from "../../scripts/types.ts"; |
7 | 5 | import { fs, setMockFiles } from "../fs.mock.mts"; |
8 | 6 |
|
9 | | -function getExampleManifest() { |
10 | | - const p = new URL("../../example/package.json", import.meta.url); |
11 | | - const manifest = readJSONFile<Manifest>(p); |
12 | | - return manifest; |
| 7 | +function getCatalog(): Record<string, string> { |
| 8 | + const { stdout } = spawnSync("yarn", ["config", "get", "catalog", "--json"], { |
| 9 | + shell: process.platform === "win32", |
| 10 | + }); |
| 11 | + return JSON.parse(stdout.toString().trim()); |
13 | 12 | } |
14 | 13 |
|
15 | 14 | describe("updatePackageManifest()", () => { |
16 | 15 | const updatePackageManifest: typeof updatePackageManifestActual = (p, cfg) => |
17 | 16 | updatePackageManifestActual(p, cfg, fs); |
18 | 17 |
|
19 | | - const exampleManifest = getExampleManifest(); |
| 18 | + const catalog = getCatalog(); |
20 | 19 | const devDependencies = { |
21 | | - "@rnx-kit/metro-config": |
22 | | - exampleManifest["devDependencies"]?.["@rnx-kit/metro-config"], |
| 20 | + "@rnx-kit/metro-config": catalog["@rnx-kit/metro-config"], |
23 | 21 | "react-native-test-app": "^0.0.1-dev", |
24 | 22 | }; |
25 | 23 |
|
|
0 commit comments