refactor(loader): resolve config after injected services
This commit is contained in:
17
vendor/include/src/index.ts
vendored
17
vendor/include/src/index.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { EntryTree, isJsExpr, type EntryOptions } from '@deepseek-ai/cordis-plugin-loader'
|
||||
import { EntryConfigResolver, EntryTree, interpolate, isJsExpr, type EntryOptions } from '@deepseek-ai/cordis-plugin-loader'
|
||||
import { Context, Service } from '@deepseek-ai/cordis'
|
||||
import { extname } from 'node:path'
|
||||
import { access, constants, readFile, rename, writeFile } from 'node:fs/promises'
|
||||
@@ -174,6 +174,21 @@ export namespace Include {
|
||||
export class Include extends EntryTree {
|
||||
static inject = ['loader']
|
||||
|
||||
/**
|
||||
* Resolve Include's own options while preserving nested entry expressions.
|
||||
* @param ctx - the Include plugin context.
|
||||
* @param config - the raw Include config.
|
||||
* @returns resolved Include options with `initial` and `patches` untouched.
|
||||
*/
|
||||
static [EntryConfigResolver](ctx: Context, config: Include.Config): Include.Config {
|
||||
const { initial, patches, ...own } = config
|
||||
return {
|
||||
...interpolate(ctx, own),
|
||||
...(initial === undefined ? {} : { initial }),
|
||||
...(patches === undefined ? {} : { patches }),
|
||||
}
|
||||
}
|
||||
|
||||
public filename: string
|
||||
private type?: string
|
||||
private readonly: boolean
|
||||
|
||||
Reference in New Issue
Block a user