const fs = require('fs'); const { exec } = require('child_process'); const path = require('path'); const TILED_PATH = '/Users/davidkotnik/Downloads/Tiled.app/Contents/MacOS/Tiled'; const MAPS_DIR = path.join(__dirname, '../assets/maps'); console.log('👀 Watching for Tiled map changes (.tmx)...'); fs.watch(MAPS_DIR, (eventType, filename) => { if (filename && filename.endsWith('.tmx')) { console.log(`📝 Detected change in ${filename}...`); const tmxFile = path.join(MAPS_DIR, filename); const jsonFile = tmxFile.replace('.tmx', '.json'); const command = `"${TILED_PATH}" --export-map "${tmxFile}" "${jsonFile}"`; exec(command, (error, stdout, stderr) => { if (error) { console.error(`❌ Export failed: ${error.message}`); return; } console.log(`✅ Exported ${filename} to JSON!`); }); } });