mirror of
https://github.com/sern-handler/handler
synced 2026-06-21 07:12:15 +00:00
Presence namespaced types removed
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import path from 'node:path';
|
||||
import assert from 'assert';
|
||||
import { createRequire } from 'node:module';
|
||||
import type { Wrapper } from '../types/core';
|
||||
import { existsSync } from 'fs';
|
||||
import type { Logging } from './interfaces';
|
||||
|
||||
|
||||
export const parseCallsite = (fpath: string) => {
|
||||
@@ -54,32 +51,3 @@ export const fmtFileName = (fileName: string) => path.parse(fileName).name;
|
||||
|
||||
export const filename = (p: string) => fmtFileName(path.basename(p));
|
||||
|
||||
const requir = createRequire(import.meta.url);
|
||||
|
||||
export function loadConfig(wrapper: Wrapper | 'file', log: Logging | undefined): Wrapper {
|
||||
if (wrapper !== 'file') {
|
||||
return wrapper;
|
||||
}
|
||||
log?.info({ message: 'Experimental loading of sern.config.json'});
|
||||
const config = requir(path.resolve('sern.config.json'));
|
||||
|
||||
const makePath = (dir: PropertyKey) =>
|
||||
config.language === 'typescript'
|
||||
? path.join('dist', config.paths[dir]!)
|
||||
: path.join(config.paths[dir]!);
|
||||
|
||||
log?.info({ message: 'Loading config: ' + JSON.stringify(config, null, 4) });
|
||||
const commandsPath = makePath('commands');
|
||||
|
||||
log?.info({ message: `Commands path is set to ${commandsPath}` });
|
||||
let eventsPath: string | undefined;
|
||||
if (config.paths.events) {
|
||||
eventsPath = makePath('events');
|
||||
log?.info({ message: `Events path is set to ${eventsPath} `});
|
||||
}
|
||||
|
||||
return { defaultPrefix: config.defaultPrefix,
|
||||
commands: commandsPath,
|
||||
events: eventsPath };
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user