refactor: remove mock-fs from dev dependency

This commit is contained in:
harttle
2019-02-19 22:28:27 +08:00
parent f432aade6a
commit 852c6ad453
70 changed files with 711 additions and 795 deletions
+21 -1
View File
@@ -1,3 +1,5 @@
import * as _ from './util/underscore'
export interface LiquidOptions {
/** `root` is a directory or an array of directories to resolve layouts and includes, as well as the filename passed in when calling `.renderFile()`. If an array, the files are looked up in the order they occur in the array. Defaults to `["."]` */
root?: string | string[]
@@ -23,7 +25,11 @@ export interface LiquidOptions {
greedy?: boolean
}
export const defaultOptions: LiquidOptions = {
export interface NormalizedOptions extends LiquidOptions {
root?: string[]
}
export const defaultOptions: NormalizedOptions = {
root: ['.'],
cache: false,
extname: '',
@@ -36,3 +42,17 @@ export const defaultOptions: LiquidOptions = {
strict_filters: false,
strict_variables: false
}
export function normalize (options: LiquidOptions): NormalizedOptions {
options = options || {}
if (options.hasOwnProperty('root')) {
options.root = normalizeStringArray(options.root)
}
return options as NormalizedOptions
}
function normalizeStringArray (value: string | string[]): string[] {
if (_.isArray(value)) return value as string[]
if (_.isString(value)) return [value as string]
return []
}