@typecad/kicad-symbols
Version:
Intelligent fuzzy search for KiCad symbols with CLI interface
34 lines (33 loc) • 946 B
JavaScript
import { KiCAD as BaseKiCAD, kicad_cli_path, kicad_path } from '@typecad/typecad/dist/kicad.js';
export { kicad_cli_path };
export let kicad_symbols_path;
export class KiCAD {
constructor() {
new BaseKiCAD();
if (kicad_path) {
const libraryPaths = new BaseKiCAD().getLibraryPaths();
if (libraryPaths.symbols) {
kicad_symbols_path = libraryPaths.symbols;
}
}
}
getSymbolsPath() {
return kicad_symbols_path;
}
getCliPath() {
return kicad_cli_path;
}
async hasLocalSymbols() {
if (!kicad_symbols_path) {
return false;
}
try {
const fs = await import('node:fs');
const files = await fs.promises.readdir(kicad_symbols_path);
return files.some(file => file.endsWith('.kicad_sym'));
}
catch (error) {
return false;
}
}
}