Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When specifying -t tsx, base component filename on manufacturer part number #33

Merged
merged 1 commit into from
Jul 22, 2024
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
22 changes: 18 additions & 4 deletions cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import packageJson from "../package.json"
import { EasyEdaJsonSchema } from "lib/schemas/easy-eda-json-schema"
import { convertRawEasyEdaToTs } from "lib/convert-to-typescript-component"
import * as path from "path"
import { normalizeManufacturerPartNumber } from "lib"

const program = new Command()

Expand All @@ -33,12 +34,25 @@ program
rawEasyEdaJson = await fetchEasyEDAComponent(options.input)
}

if (options.type === "ts") options.type = "tsx"
const tsxExtension = "tsx"
if (options.type === "ts") options.type = tsxExtension

if (!options.output && options.type) {
options.output = `${path.basename(options.input).split(".")[0]}.${
options.type
}`
let filename = path.basename(options.input).split(".")[0]

if (options.type === tsxExtension) {
const {
dataStr: {
head: {
c_para: { "Manufacturer Part": manufacturerPartNumber },
},
},
} = rawEasyEdaJson

filename = normalizeManufacturerPartNumber(manufacturerPartNumber)
andrii-balitskyi marked this conversation as resolved.
Show resolved Hide resolved
}

options.output = `${filename}.${options.type}`
}

if (!options.output) {
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"name": "easyeda",
"type": "module",
"version": "0.0.22",
"files": [
"dist"
],
"files": ["dist"],
"repository": {
"type": "git",
"url": "https://github.com/tscircuit/easyeda-converter"
Expand Down
Loading