Update utils.js

This commit is contained in:
Aleksandr Statciuk 2021-10-06 03:02:11 +03:00
parent d231ba624a
commit 1f137c094c
1 changed files with 1 additions and 8 deletions

View File

@ -14,14 +14,7 @@ const utils = {}
const defaultUserAgent = const defaultUserAgent =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71' 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71'
utils.loadConfig = function (options) { utils.loadConfig = function (config, options = {}) {
const file = options.config
if (!file) throw new Error('Path to [site].config.js is missing')
console.log(`Loading '${file}'...`)
const configPath = path.resolve(file)
const config = require(configPath)
if (!config.site) throw new Error("The required 'site' property is missing") if (!config.site) throw new Error("The required 'site' property is missing")
if (!config.url) throw new Error("The required 'url' property is missing") if (!config.url) throw new Error("The required 'url' property is missing")
if (typeof config.url !== 'function' && typeof config.url !== 'string') if (typeof config.url !== 'function' && typeof config.url !== 'string')