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) { continue; } if (!rule.pattern) { return rule.destination; } const regex = new RegExp(rule.pattern); if (regex.test(path.basename(filename))) { return rule.destination; } } return null; } function isCadFile(filename) { const ext = path.extname(filename).slice(1).toLowerCase(); return ['prt', 'asm', 'dwr'].includes(ext); } module.exports = { findDestination, isCadFile };