37 lines
833 B
JavaScript
37 lines
833 B
JavaScript
#!/usr/bin/env node
|
|
const CronJob = require('cron').CronJob;
|
|
|
|
// load env variables from file
|
|
require('dotenv').config();
|
|
|
|
// TODO:
|
|
// parse arguments - we should run just 1 FCA per go &
|
|
// have option to run selected company from selected NCA
|
|
const argv = require('yargs').argv;
|
|
|
|
// load helper libs etc
|
|
// const Fca = require('./ncas/fca');
|
|
|
|
const Netherlands = require('./ncas/nl');
|
|
|
|
async function run() {
|
|
const nlScraper = new Netherlands();
|
|
|
|
if (typeof(process.env.NL_CRON) === 'string' )
|
|
new CronJob(process.env.NL_CRON, async function() {
|
|
await nlScraper.run();
|
|
}, null, true);
|
|
|
|
if (process.env.SCRAPE_START === nlScraper.id)
|
|
await nlScraper.run();
|
|
|
|
console.log('NL Launched');
|
|
}
|
|
|
|
process.once('uncaughtException', function caught(err) {
|
|
console.error('Uncaught', err);
|
|
done = true;
|
|
});
|
|
|
|
run();
|