Skip to content

Commit

Permalink
fix: Fix context config prototype to ballow serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 27, 2024
1 parent 2178c11 commit 195d30a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,22 @@ type ConfigUtils = {
export type Config<T> = T & ConfigUtils;

export function withConfigUtils<T extends Hash = Hash>(path: string | null, config: T): Config<T> {
return {
...config,
resolve: (subpath: string): AbsolutePath => {
if (path === null) {
return resolve(subpath) as AbsolutePath;
}

return resolve(dirname(path), subpath) as AbsolutePath;
return Object.create(config, {
resolve: {
enumerable: false,
value: (subpath: string): AbsolutePath => {
if (path === null) {
return resolve(subpath) as AbsolutePath;
}

return resolve(dirname(path), subpath) as AbsolutePath;
},
},
[configPath]: path === null ? path : resolve(path),
};
[configPath]: {
enumerable: false,
value: path === null ? path : resolve(path),
}
});
}

export async function resolveConfig<T extends Hash = {}>(
Expand Down

0 comments on commit 195d30a

Please sign in to comment.