mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
refactor: make loader.shouldLoadRelative public
This commit is contained in:
+5
-5
@@ -35,10 +35,14 @@ export class Loader {
|
||||
throw this.lookupError(file, dirs)
|
||||
}
|
||||
|
||||
public shouldLoadRelative (referencedFile: string) {
|
||||
return this.options.relativeReference && this.rRelativePath.test(referencedFile)
|
||||
}
|
||||
|
||||
public * candidates (file: string, dirs: string[], currentFile?: string, enforceRoot?: boolean) {
|
||||
const { fs, extname } = this.options
|
||||
if (this.shouldLoadRelative(file) && currentFile) {
|
||||
const referenced = fs.resolve(this.dirname(currentFile), file, extname, this.options)
|
||||
const referenced = fs.resolve(this.dirname(currentFile), file, extname)
|
||||
for (const dir of dirs) {
|
||||
if (!enforceRoot || this.withinDir(referenced, dir)) {
|
||||
// the relatively referenced file is within one of root dirs
|
||||
@@ -64,10 +68,6 @@ export class Loader {
|
||||
return file.startsWith(dir)
|
||||
}
|
||||
|
||||
private shouldLoadRelative (referencedFile: string) {
|
||||
return this.options.relativeReference && this.rRelativePath.test(referencedFile)
|
||||
}
|
||||
|
||||
private dirname (path: string) {
|
||||
const fs = this.options.fs
|
||||
assert(fs.dirname, '`fs.dirname` is required for relative reference')
|
||||
|
||||
Reference in New Issue
Block a user