You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
940 B
41 lines
940 B
8 months ago
|
import cron from 'node-cron'
|
||
|
|
||
|
import { resolveEnabledConfig } from './helpers/resolver.ts'
|
||
|
import logger from './helpers/logger.ts'
|
||
|
|
||
|
import run from './_run.ts'
|
||
|
|
||
|
/**
|
||
|
* Run all Configs that are in Directory /resources/configs/enabled
|
||
|
*
|
||
|
* @author Björn Hase <me@herr-hase.wtf>
|
||
|
* @license http://opensource.org/licenses/MIT The MIT License
|
||
|
* @link https://git.node001.net/HerrHase/super-hog.git
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
// get all configs from resolveEnabledConfig
|
||
|
const configs = resolveEnabledConfig()
|
||
|
|
||
|
// check if there is any valid config
|
||
|
if (configs.length === 0) {
|
||
|
throw new Error('No valid config found!')
|
||
|
}
|
||
|
|
||
|
// running through configs
|
||
|
for (const config in configs)
|
||
|
|
||
|
// check for cron
|
||
|
if (!config.hasOwnProperty('cron')) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* adding task to schedule, using cron
|
||
|
*
|
||
|
*/
|
||
|
const task = cron.schedule(config.cron, async() => {
|
||
|
const docket = await run(config, docket)
|
||
|
})
|
||
|
}
|