Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/publish/__tests__/discover-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ test("retains checkout-path behavior when the root config is absent", () => {
).toEqual({ path: "./packages/cli" });
});

test("does not discover workspaces for the checkout root", () => {
const execFile = vi.fn(() => {
throw new Error("workspace list is unavailable");
});

expect(
discoverLocation({
input: { path: "." },
repositoryDirectory: "__repo__",
exists: () => true,
execFile,
})
).toEqual({ path: "." });
expect(execFile).not.toHaveBeenCalled();
});

test("fails closed when non-root workspace discovery is unavailable", () => {
const execFile = vi.fn(() => {
throw new Error("workspace list is unavailable");
});

expect(() =>
discoverLocation({
input: { path: "./packages/cli" },
repositoryDirectory: "__repo__",
exists: () => true,
execFile,
})
).toThrow("workspace list is unavailable");
expect(execFile).toHaveBeenCalledOnce();
});

test("discovers exact workspace paths using the released Craft image", () => {
const execFile = vi.fn(() => '["packages/CLI"]');

Expand Down
4 changes: 4 additions & 0 deletions src/publish/discover-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function discoverLocation({
exists,
execFile,
}) {
if (input.path === ".") {
return { path: "." };
}

return resolvePublishLocation({
path: input.path,
workspaceNames: getWorkspaceNames({ repositoryDirectory, exists, execFile }),
Expand Down
Loading