feat: unifica lo smistamento CAD su destinazione unica configurabile da UI
This commit is contained in:
@@ -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 };
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user