Skip to content
Open
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
2 changes: 1 addition & 1 deletion cli/build/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const registerBuild = (program: Command) => {
hasAnyImageFormatSelected(imageFormatSelection),
)
const shouldGenerateAllPreviewImages = Boolean(
resolvedOptions?.allImages,
resolvedOptions?.allImages || hasExplicitImageFormatSelection,
)
const shouldGeneratePreviewAssetsInWorker = Boolean(
resolvedOptions?.ci &&
Expand Down
32 changes: 31 additions & 1 deletion tests/cli/build/build-output-flags.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from "bun:test"
import { expect, test } from "bun:test"
import { readFile, stat, writeFile } from "node:fs/promises"
import path from "node:path"
import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture"
Expand Down Expand Up @@ -155,6 +155,36 @@ test("build --pcb-only generates only pcb.svg", async () => {
).rejects.toBeTruthy()
}, 30_000)

test("build --pcb-svgs --schematic-svgs places SVGs in each component subdirectory", async () => {
const { tmpDir, runCommand } = await getCliTestFixture()
const firstCircuit = path.join(tmpDir, "first.circuit.tsx")
const secondCircuit = path.join(tmpDir, "second.circuit.tsx")
await writeFile(firstCircuit, circuitCode)
await writeFile(secondCircuit, circuitCode)
await writeFile(path.join(tmpDir, "package.json"), "{}")

await runCommand(`tsci build --pcb-svgs --schematic-svgs`)

// SVGs should be in each component's subdirectory
for (const name of ["first", "second"]) {
const pcbSvg = await readFile(
path.join(tmpDir, "dist", name, "pcb.svg"),
"utf-8",
)
expect(pcbSvg).toContain("<svg")

const schematicSvg = await readFile(
path.join(tmpDir, "dist", name, "schematic.svg"),
"utf-8",
)
expect(schematicSvg).toContain("<svg")
}

// SVGs should NOT be at dist root
expect(stat(path.join(tmpDir, "dist", "pcb.svg"))).rejects.toBeTruthy()
expect(stat(path.join(tmpDir, "dist", "schematic.svg"))).rejects.toBeTruthy()
}, 60_000)

test("build --schematic-only generates only schematic.svg", async () => {
const { tmpDir, runCommand } = await getCliTestFixture()
const circuitPath = path.join(tmpDir, "preview.circuit.tsx")
Expand Down
Loading