diff options
author | 2023-10-14 12:58:30 -0700 | |
---|---|---|
committer | 2023-10-14 12:58:30 -0700 | |
commit | f9add8b6bea4df3cdbd56a21f17e4cab1a854e4e (patch) | |
tree | 8e5306104d81c67b771181337bba02cd9ec39453 /test/cli/install/migration/migrate.test.ts | |
parent | 81a1a58d66c598ea35c42453d0ba4c6341a940fc (diff) | |
parent | 9b5e66453b0879ed77b71dcdbe50e4efa184261e (diff) | |
download | bun-sdl.tar.gz bun-sdl.tar.zst bun-sdl.zip |
Merge branch 'main' into sdlsdl
Diffstat (limited to 'test/cli/install/migration/migrate.test.ts')
-rw-r--r-- | test/cli/install/migration/migrate.test.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/cli/install/migration/migrate.test.ts b/test/cli/install/migration/migrate.test.ts new file mode 100644 index 000000000..28ccac2a0 --- /dev/null +++ b/test/cli/install/migration/migrate.test.ts @@ -0,0 +1,54 @@ +import fs from "fs"; +import { test, expect } from "bun:test"; +import { bunEnv, bunExe } from "harness"; +import { join } from "path"; +import { mkdtempSync } from "js/node/fs/export-star-from"; +import { tmpdir } from "os"; + +test("migrate from npm during `bun add`", async () => { + const testDir = mkdtempSync(join(tmpdir(), "migrate-")); + + fs.writeFileSync( + join(testDir, "package.json"), + JSON.stringify({ + name: "test3", + dependencies: { + "svelte": "*", + }, + }), + ); + fs.cpSync(join(import.meta.dir, "add-while-migrate-fixture.json"), join(testDir, "package-lock.json")); + + Bun.spawnSync([bunExe(), "add", "lodash@4.17.21"], { + env: bunEnv, + cwd: testDir, + }); + + expect(fs.existsSync(join(testDir, "node_modules/lodash"))).toBeTrue(); + + const svelte_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/svelte/package.json"), "utf8")).version; + expect(svelte_version).toBe("4.0.0"); + + const lodash_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/lodash/package.json"), "utf8")).version; + expect(lodash_version).toBe("4.17.21"); +}); + +// Currently this upgrades svelte :( +test.todo("migrate workspace from npm during `bun add`", async () => { + const testDir = join(tmpdir(), "migrate-" + Math.random().toString(36).slice(2)); + + fs.cpSync(join(import.meta.dir, "add-while-migrate-workspace"), testDir, { recursive: true }); + + Bun.spawnSync([bunExe(), "add", "lodash@4.17.21"], { + env: bunEnv, + cwd: join(testDir, "packages", "a"), + }); + + expect(fs.existsSync(join(testDir, "node_modules/lodash"))).toBeTrue(); + + const lodash_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/lodash/package.json"), "utf8")).version; + expect(lodash_version).toBe("4.17.21"); + + const svelte_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/svelte/package.json"), "utf8")).version; + expect(svelte_version).toBe("3.0.0"); +}); |