-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core): add ManifestStore for startup manifest caching #5844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ import globby from 'globby'; | |||||||||||||||||||||||||||
| import { isClass, isGeneratorFunction, isAsyncFunction, isPrimitive } from 'is-type-of'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import utils, { type Fun } from '../utils/index.ts'; | ||||||||||||||||||||||||||||
| import type { ManifestStore } from './manifest.ts'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const debug = debuglog('egg/core/file_loader'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -49,6 +50,8 @@ export interface FileLoaderOptions { | |||||||||||||||||||||||||||
| /** set property's case when converting a filepath to property list. */ | ||||||||||||||||||||||||||||
| caseStyle?: CaseStyle | CaseStyleFunction; | ||||||||||||||||||||||||||||
| lowercaseFirst?: boolean; | ||||||||||||||||||||||||||||
| /** Startup manifest for caching globby scans and collecting results */ | ||||||||||||||||||||||||||||
| manifest?: ManifestStore; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export interface FileLoaderParseItem { | ||||||||||||||||||||||||||||
|
|
@@ -193,8 +196,11 @@ export class FileLoader { | |||||||||||||||||||||||||||
| const items: FileLoaderParseItem[] = []; | ||||||||||||||||||||||||||||
| debug('[parse] parsing directories: %j', directories); | ||||||||||||||||||||||||||||
| for (const directory of directories) { | ||||||||||||||||||||||||||||
| const filepaths = globby.sync(files, { cwd: directory }); | ||||||||||||||||||||||||||||
| debug('[parse] globby files: %o, cwd: %o => %o', files, directory, filepaths); | ||||||||||||||||||||||||||||
| const manifest = this.options.manifest; | ||||||||||||||||||||||||||||
| const filepaths = manifest | ||||||||||||||||||||||||||||
| ? manifest.globFiles(directory, () => globby.sync(files, { cwd: directory })) | ||||||||||||||||||||||||||||
| : globby.sync(files, { cwd: directory }); | ||||||||||||||||||||||||||||
| debug('[parse] files: %o, cwd: %o => %o', files, directory, filepaths); | ||||||||||||||||||||||||||||
killagu marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
| for (const filepath of filepaths) { | ||||||||||||||||||||||||||||
| const fullpath = path.join(directory, filepath); | ||||||||||||||||||||||||||||
| if (!fs.statSync(fullpath).isFile()) continue; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| if (!fs.statSync(fullpath).isFile()) continue; | |
| let stats: fs.Stats; | |
| try { | |
| stats = fs.statSync(fullpath); | |
| } catch (err) { | |
| const e = err as NodeJS.ErrnoException; | |
| if (e.code === 'ENOENT') { | |
| debug('[parse] skip missing file from manifest: %s', fullpath); | |
| continue; | |
| } | |
| throw err; | |
| } | |
| if (!stats.isFile()) continue; |
Uh oh!
There was an error while loading. Please reload this page.