const jsonfile = require('jsonfile'); require('dotenv').config(); (function() { const apps = []; const list = [ { 'cron':'CY_CRON', 'start':'CY', 'name':'CY', 'script':'cy.js' }, { 'cron':'CZ_CRON', 'start':'CZ', 'name':'CZ', 'script':'cz.js' }, { 'cron':'DE_CRON', 'start':'DE', 'name':'DE', 'script':'de.js' }, { 'cron':'DK_CRON', 'start':'DK', 'name':'DK', 'script':'dk.js' }, { 'cron':'FR_CRON', 'start':'FR', 'name':'FR', 'script':'fr.js' }, { 'cron':'GI_CRON', 'start':'GI', 'name':'GI', 'script':'gi.js' }, { 'cron':'IE_CRON', 'start':'IE', 'name':'IE', 'script':'ie.js' }, { 'cron':'IT_CRON', 'start':'IT', 'name':'IT', 'script':'it.js' }, { 'cron':'LU_CRON', 'start':'LU', 'name':'LU', 'script':'lu.js' }, { 'cron':'MT_CRON', 'start':'MT', 'name':'MT', 'script':'mt.js' }, { 'cron':'NL_CRON', 'start':'NL', 'name':'NL', 'script':'nl.js' }, { 'cron':'PL_CRON', 'start':'PL', 'name':'PL', 'script':'pl.js' }, { 'cron':'SE_CRON', 'start':'SE', 'name':'SE', 'script':'se.js' }, { 'cron':'SK_CRON', 'start':'SK', 'name':'SK', 'script':'sk.js' }, { 'cron':'PT_CRON', 'start':'PT', 'name':'PT', 'script':'pt.js' } ]; for(const item of list) if (typeof process.env[item.cron] !== 'undefined' || process.env.SCRAPE_START === item.start) { const newItem = { 'name' : item.name, 'script' : item.script, 'env': { 'NODE_ENV': 'production' }, 'env_production' : { 'NODE_ENV': 'production' }, 'autorestart' : true, 'max_restarts': 3, 'restart_delay': 4000 }; apps.push(newItem); } console.log(apps); })();