Skip to content

Commit

Permalink
file path fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imrishabh18 committed Jul 30, 2024
1 parent bd1955a commit f8ea1d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tests/fixtures/pcb-snapshot-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { AnySoupElement } from "@tscircuit/soup"
import { circuitToPng } from "circuit-to-png"
import { mkdir, writeFile } from "node:fs/promises"
import path from "node:path"
import { fileURLToPath } from "node:url"

export const writePcbSnapshotPng = async (
fileName: string,
Expand All @@ -10,9 +11,9 @@ export const writePcbSnapshotPng = async (
) => {
const pngBuffer = circuitToPng(circuit, "pcb")
const fileNameWithoutSpaces = fileName.replaceAll(" ", "-")
const directoryPath = dirName
.split(`/${fileNameWithoutSpaces}`)[0]
.replace(/^file:\/\//, "")

const filePath = fileURLToPath(dirName)
const directoryPath = path.dirname(filePath)
const snapshotDir = path.join(directoryPath, "__snapshots__")

try {
Expand Down
7 changes: 4 additions & 3 deletions tests/fixtures/schematic-snapshot-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { AnySoupElement } from "@tscircuit/soup"
import { circuitToPng } from "circuit-to-png"
import { mkdir, writeFile } from "node:fs/promises"
import path from "node:path"
import { fileURLToPath } from "node:url"

export const writeSchematicSnapshotPng = async (
fileName: string,
Expand All @@ -10,9 +11,9 @@ export const writeSchematicSnapshotPng = async (
) => {
const pngBuffer = circuitToPng(circuit, "schematic")
const fileNameWithoutSpaces = fileName.replaceAll(" ", "-")
const directoryPath = dirName
.split(`/${fileNameWithoutSpaces}`)[0]
.replace(/^file:\/\//, "")

const filePath = fileURLToPath(dirName)
const directoryPath = path.dirname(filePath)
const snapshotDir = path.join(directoryPath, "__snapshots__")

try {
Expand Down

0 comments on commit f8ea1d3

Please sign in to comment.