let runAnalyze = runCompile.then(() => { // If we are first run, then build the .tests files if(firstCompile && !program.skipAnalysis) { firstCompile = false; let analyzeKeyboard = function(keyboard) { const locator = keyboard.shortname+'/'+keyboard.id; const kmx = path.join(config.KEYBOARDS_ROOT, config.KEYBOARDS_GROUP, locator, 'build', keyboard.id+'.kmx'); const testsPath = path.join(config.KEYBOARDS_ROOT, config.KEYBOARDS_GROUP, locator, 'tests'); const tests = path.join(testsPath, keyboard.id+'.tests'); if(!fs.existsSync(kmx)) { // TODO: kmanalyze should really call the compiler to build an intermediate .kmx // for use with web. This should not be that hard to do... console.log('Cannot currently generate tests without a .kmx for '+keyboard.id); return true; } if(!fs.existsSync(testsPath)) { fs.mkdirSync(testsPath); } console.log(`Building test cases for ${locator}`); // TODO: Find kmanalyze outside the repo. This forces Windows-dependence right now return util.runProcess('../../../windows/bin/developer/kmanalyze.exe', [kmx, tests], {}, true); }; let keyboards = program.keyboards.length ? program.keyboards.map((locator) => util.parseLocator(locator)) : util.getKeyboardFolders(KEYBOARDS_ROOT, false); return forEachPromise(keyboards, analyzeKeyboard); } });