Skip to content

Commit

Permalink
normalize options within flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Apr 5, 2020
1 parent f2f6f2c commit 3bdad3c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions lib/services/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const {
} = require('../utils/fp')



const defaultOptions = {}

const defaultMeta = {
bundle: false,
recursive: true,
Expand All @@ -21,18 +18,12 @@ const defaultMeta = {
preload: false,
}

const parseOptionExtensions = ({ extensions }) => ({
extensions: Array.isArray(extensions) ? extensions : extensions.split(','),
})

const parseOptions = options => ({
...options,
...parseOptionExtensions(options),
})

module.exports = async function scanner(inputOptions, metaParser) {
const options = parseOptions({ ...defaultOptions, ...inputOptions })
function normalizeOptions({ options }) {
const { extensions } = options
options.extensions = Array.isArray(extensions) ? extensions : extensions.split(',')
}

module.exports = async function scanner(options, metaParser) {
return await pipeAsync(
x => {
x.options = options;
Expand All @@ -41,6 +32,7 @@ module.exports = async function scanner(inputOptions, metaParser) {
x.tree = { meta: { untouched: true }, root: true, dir: [] }
},
// createRoot, // dir => ({ dir, ...root })
normalizeOptions,
generateFileTree, // => dir
removeUnderscoredDirs, // _private => false
defineFiles, // file => ({ isLayout, isReset, isIndex, isFallback })
Expand Down

0 comments on commit 3bdad3c

Please sign in to comment.