Skip to content

Commit 4bacbaf

Browse files
committed
Scope pathToProjectSlug leading-dash assertion to POSIX
On Windows, resolve('./foo') returns a drive-letter path like D:\...\foo. The normalizer rewrites backslashes to forward slashes and the encoder replaces [./] with '-', producing e.g. D--a-CodeForge-foo. Starts with a letter, not a dash. Guard the POSIX-only startsWith('-') assertion on process.platform so Windows CI passes while keeping the POSIX contract tested.
1 parent 62f55d4 commit 4bacbaf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cli/tests/tokens.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ describe("pathToProjectSlug", () => {
3838
const abs = pathToProjectSlug("./foo");
3939
// Resolved path always ends with /foo; after encoding trailing segment is -foo
4040
expect(abs.endsWith("-foo")).toBe(true);
41-
expect(abs.startsWith("-")).toBe(true);
41+
// On POSIX, resolved absolute paths start with `/` which encodes to `-`.
42+
// On Windows they start with a drive letter (e.g. `D:`) so the leading
43+
// `-` assertion is POSIX-only.
44+
if (process.platform !== "win32") {
45+
expect(abs.startsWith("-")).toBe(true);
46+
}
4247

4348
const abs2 = pathToProjectSlug("../bar");
4449
expect(abs2.endsWith("-bar")).toBe(true);

0 commit comments

Comments
 (0)