mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 14:00:39 -07:00
feat: support require.resolve for lookup, see #168
This commit is contained in:
@@ -4,4 +4,5 @@ export default interface IFS {
|
||||
existsSync: (filepath: string) => boolean;
|
||||
readFileSync: (filepath: string) => string;
|
||||
resolve: (root: string, file: string, ext: string) => string;
|
||||
fallback?: (file: string) => string | undefined;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ const fs: IFS = {
|
||||
resolve: (root: string, file: string, ext: string) => {
|
||||
if (!extname(file)) file += ext
|
||||
return resolve(root, file)
|
||||
},
|
||||
fallback: (file: string) => {
|
||||
try {
|
||||
return require.resolve(file)
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user