Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiboSoftwareDev committed Sep 26, 2024
1 parent 0363c1f commit 18bd411
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 60 deletions.
6 changes: 3 additions & 3 deletions cli/lib/export-fns/export-gerbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const exportGerbersToFile = async (
},
ctx,
)
console.log(soup,'soup')
console.log(soup, "soup")

console.log(kleur.gray("[soup to gerber json]..."))
const gerber_layer_cmds = convertSoupToGerberCommands(soup, {
Expand Down Expand Up @@ -92,7 +92,7 @@ export const exportGerbersToZipBuffer = async (
) => {
const tempDir = Path.join(".tscircuit", "tmp-gerber-zip")
fs.mkdirSync(tempDir, { recursive: true })
console.log('step two')
console.log("step two")
await exportGerbersToFile(
{
example_file_path: params.example_file_path,
Expand All @@ -101,7 +101,7 @@ console.log('step two')
},
ctx,
)
console.log('step last')
console.log("step last")

const buffer = fs.readFileSync(Path.join(tempDir, "gerbers.zip"))

Expand Down
99 changes: 49 additions & 50 deletions cli/lib/soupify/run-entrypoint-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,57 @@ export const runEntrypointFile = async (
}: { tmpEntrypointPath: string; tmpOutputPath: string },
ctx: Pick<AppContext, "runtime" | "params">,
) => {
try{
console.log(1)
debug(`using runtime ${ctx.runtime}`)
const processCmdPart1 =
ctx.runtime === "node"
? $`npx tsx ${tmpEntrypointPath}`
: $`bun ${tmpEntrypointPath}`
console.log(2)
try {
console.log(1)
debug(`using runtime ${ctx.runtime}`)
const processCmdPart1 =
ctx.runtime === "node"
? $`npx tsx ${tmpEntrypointPath}`
: $`bun ${tmpEntrypointPath}`
console.log(2)

debug(`starting process....`)
console.log(debug.enabled)

try{
const processResult = await processCmdPart1
.stderr(debug.enabled ? "inheritPiped" : "piped")
.stdout(debug.enabled ? "inheritPiped" : "piped")
}catch(e){
console.log(e)
}

console.log(tmpOutputPath
)
const rawSoup = await readFile(tmpOutputPath, "utf-8")
// const errText = processResult.stderr
debug(`starting process....`)
console.log(debug.enabled)

console.log(4)
if (ctx.params.cleanup !== false) {
debug(`deleting ${tmpEntrypointPath}`)
await unlink(tmpEntrypointPath)
debug(`deleting ${tmpOutputPath}`)
await unlink(tmpOutputPath)
}

try {
debug(`parsing result of soupify...`)
const soup = JSON.parse(rawSoup)

if (soup.COMPILE_ERROR) {
// console.log(kleur.red(`Failed to compile ${filePath}`))
console.log(kleur.red(soup.COMPILE_ERROR))
throw new Error(soup.COMPILE_ERROR)
try {
const processResult = await processCmdPart1
.stderr(debug.enabled ? "inheritPiped" : "piped")
.stdout(debug.enabled ? "inheritPiped" : "piped")
} catch (e) {
console.log(e)
}
console.log('final')
return soup
} catch (e: any) {
// console.log(kleur.red(`Failed to parse result of soupify: ${e.toString()}`))
const t = Date.now()
console.log(`Dumping raw output to .tscircuit/err-${t}.log`)
// writeFileSync(`.tscircuit/err-${t}.log`, rawSoup + "\n\n" + errText)
// throw new Error(errText)

console.log(tmpOutputPath)
const rawSoup = await readFile(tmpOutputPath, "utf-8")
// const errText = processResult.stderr

console.log(4)
if (ctx.params.cleanup !== false) {
debug(`deleting ${tmpEntrypointPath}`)
await unlink(tmpEntrypointPath)
debug(`deleting ${tmpOutputPath}`)
await unlink(tmpOutputPath)
}

try {
debug(`parsing result of soupify...`)
const soup = JSON.parse(rawSoup)

if (soup.COMPILE_ERROR) {
// console.log(kleur.red(`Failed to compile ${filePath}`))
console.log(kleur.red(soup.COMPILE_ERROR))
throw new Error(soup.COMPILE_ERROR)
}
console.log("final")
return soup
} catch (e: any) {
// console.log(kleur.red(`Failed to parse result of soupify: ${e.toString()}`))
const t = Date.now()
console.log(`Dumping raw output to .tscircuit/err-${t}.log`)
// writeFileSync(`.tscircuit/err-${t}.log`, rawSoup + "\n\n" + errText)
// throw new Error(errText)
}
} catch (e) {
console.log(e)
}
}catch(e){
console.log(e)
}
}
13 changes: 6 additions & 7 deletions cli/lib/soupify/soupify-with-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const soupifyWithCore = async (
let { filePath, exportName } = params
exportName ??= await getExportNameFromFile(filePath)


let { tmpEntrypointPath, tmpOutputPath } = await getTmpEntrypointFilePath(filePath)
let { tmpEntrypointPath, tmpOutputPath } =
await getTmpEntrypointFilePath(filePath)
// Remove existing entrypoint or tmp output files
await fs.unlink(tmpEntrypointPath).catch(() => {})
await fs.unlink(tmpOutputPath).catch(() => {})
Expand Down Expand Up @@ -65,8 +65,7 @@ export const soupifyWithCore = async (
writeFileSync("${tmpOutputPath}", JSON.stringify(project.getCircuitJson()))
`.trim(),
)

return await runEntrypointFile({ tmpEntrypointPath, tmpOutputPath }, ctx)
}

)

return await runEntrypointFile({ tmpEntrypointPath, tmpOutputPath }, ctx)
}

0 comments on commit 18bd411

Please sign in to comment.