Skip to content

Commit

Permalink
address lint
Browse files Browse the repository at this point in the history
  • Loading branch information
andykais committed Mar 5, 2019
1 parent 6038946 commit 828da4f
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/settings/config/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,39 @@ const normalizeInputs = (inputsInit: ConfigInit['input']) => {
}

// TODO use type guards
const normalizeDownload = (download: DownloadConfigInit): DownloadConfig =>
typeof download === 'string'
? {
...defaults.download,
urlTemplate: download
}
: {
...defaults.download,
...download,
method: download.method || defaults.download.method
}
const normalizeDownload = (download: DownloadConfigInit): DownloadConfig | undefined =>
download === undefined
? undefined
: typeof download === 'string'
? {
...defaults.download,
urlTemplate: download
}
: {
...defaults.download,
...download,
method: download.method || defaults.download.method
}

const normalizeParse = (parse: ParseConfigInit): ParseConfig =>
typeof parse === 'string'
? {
...defaults.parse,
selector: parse
}
: {
...defaults.parse,
...parse,
expect: parse.expect || defaults.parse.expect
}
const normalizeParse = (parse: ParseConfigInit): ParseConfig | undefined =>
parse === undefined
? undefined
: typeof parse === 'string'
? {
...defaults.parse,
selector: parse
}
: {
...defaults.parse,
...parse,
expect: parse.expect || defaults.parse.expect
}

const normalizeDefinition = (scrapeConfig: ScrapeConfigInit): ScrapeConfig => ({
...defaults.definition,
...scrapeConfig,
download:
scrapeConfig.download === undefined ? undefined : normalizeDownload(scrapeConfig.download),
parse: scrapeConfig.parse === undefined ? undefined : normalizeParse(scrapeConfig.parse)
download: normalizeDownload(scrapeConfig.download),
parse: normalizeParse(scrapeConfig.parse)
})

const normalizeScraperDefs = (scraperDefs: ConfigInit['scrapers']) => {
Expand Down

0 comments on commit 828da4f

Please sign in to comment.