Keep copied source packages out of parent Git repositories
This commit is contained in:
1 parent
2654e1b870
commit
fa304ca4dc
4 files changed
+33
-4
No files matched your search
+11
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { copyFileSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { formatDevVersion, parseGitDescribe, resolveVersionInfo } from "./version.js";
|
||||
@@ -84,6 +84,16 @@ describe("resolveVersionInfo configuration modes", () => {
|
||||
expect(resolveVersionInfo({ env: emptyBuildEnv })).toEqual(expected);
|
||||
// Explicit cwd remains available for callers/tests that intentionally inspect another checkout.
|
||||
expect(resolveVersionInfo({ env: emptyBuildEnv, cwd: dir }).git?.baseVersion).toBe("99.99.99");
|
||||
const copy = join(dir, "node_modules", "seal-use");
|
||||
mkdirSync(join(copy, "src"), { recursive: true });
|
||||
copyFileSync(join(repoRoot, "src", "version.ts"), join(copy, "src", "version.ts"));
|
||||
copyFileSync(join(repoRoot, "package.json"), join(copy, "package.json"));
|
||||
const child = spawnSync(process.execPath, ["-e", `import { VERSION_INFO } from ${JSON.stringify(join(copy, "src", "version.ts"))}; console.log(JSON.stringify(VERSION_INFO))`], {
|
||||
cwd: dir, encoding: "utf8", env: { ...process.env, ...emptyBuildEnv }
|
||||
});
|
||||
expect(child.status).toBe(0);
|
||||
expect(JSON.parse(child.stdout)).toMatchObject({ version: expect.stringContaining("+local"), channel: "dev" });
|
||||
expect(JSON.parse(child.stdout).git).toBeUndefined();
|
||||
} finally {
|
||||
process.chdir(originalCwd);
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
|
||||
Reference in new issue
Block a user