feat: unifica lo smistamento CAD su destinazione unica configurabile da UI

This commit is contained in:
2026-03-05 16:11:01 +01:00
parent 7008f57119
commit cc38413400
8 changed files with 194 additions and 130 deletions

View File

@@ -1,20 +0,0 @@
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
const configPath = path.join(os.homedir(), '.cad-router-config.json');
const defaultConfigPath = path.join(__dirname, '..', 'config', 'defaultConfig.json');
async function loadConfig() {
if (await fs.pathExists(configPath)) {
return fs.readJson(configPath);
}
const defaultConfig = await fs.readJson(defaultConfigPath);
await fs.writeJson(configPath, defaultConfig, { spaces: 2 });
return defaultConfig;
}
loadConfig.getConfigPath = () => configPath;
module.exports = { loadConfig };

View File

@@ -2,6 +2,11 @@ const path = require('path');
function findDestination(filename, config) {
const ext = path.extname(filename).slice(1).toLowerCase();
const globalDestination = typeof config?.destination === 'string' ? config.destination.trim() : '';
if (globalDestination && ['prt', 'asm', 'dwr'].includes(ext)) {
return globalDestination;
}
for (const rule of config.rules || []) {
if ((rule.ext || '').toLowerCase() !== ext) {
@@ -23,7 +28,7 @@ function findDestination(filename, config) {
function isCadFile(filename) {
const ext = path.extname(filename).slice(1).toLowerCase();
return ['prt', 'asm', 'drw'].includes(ext);
return ['prt', 'asm', 'dwr'].includes(ext);
}
module.exports = { findDestination, isCadFile };