feat: aliasedConfig

This commit is contained in:
cha0s 2023-12-29 02:28:20 -06:00
parent 472f120a5a
commit c68bb3b6f7
2 changed files with 17 additions and 1 deletions

View File

@ -40,6 +40,19 @@ export default class ServerFlecks extends Flecks {
this.rcs = options.rcs || {};
}
get aliasedConfig() {
const aliases = this.aliases();
return Object.fromEntries(
Object.entries(
this.config,
)
.map(([path, config]) => [
this.fleckIsAliased(path) ? `${path}:${aliases[path]}` : path,
config,
]),
);
}
aliases() {
return this.constructor.aliases(this.rcs);
}
@ -413,6 +426,9 @@ export default class ServerFlecks extends Flecks {
resolvedPath = isAbsolute(alias) ? alias : join(resolvedRoot, alias);
}
else {
if (path.startsWith('.')) {
throw new Error(`non-aliased relative path '${path}' in configuration`);
}
resolvedPath = path;
}
try {

View File

@ -186,7 +186,7 @@ export const hooks = {
'@flecks/core.starting': (flecks) => {
debug('bootstrapping flecks...');
const webFlecks = Flecks.bootstrap({
config: flecks.config,
config: flecks.aliasedConfig,
platforms: ['client', '!server'],
});
debug('bootstrapped');