Fix extension reloading and schedule hooks when using the cli to start Directus (#20188)

* Fix extension reloading and schedule hooks

Fixes #20169, fixes #20184

* Add changeset
This commit is contained in:
Nicola Krumschmidt
2023-10-25 19:48:41 +02:00
committed by GitHub
parent f29b5a167a
commit 10a59ba783
2 changed files with 15 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/api': patch
---
Fixed extension reloading and schedule hooks when using the cli to start Directus

View File

@@ -60,11 +60,13 @@ const nodeResolve = nodeResolveDefault as unknown as typeof nodeResolveDefault.d
const __dirname = dirname(fileURLToPath(import.meta.url));
const defaultOptions: ExtensionManagerOptions = {
schedule: true,
watch: env['EXTENSIONS_AUTO_RELOAD'] && env['NODE_ENV'] !== 'development',
};
export class ExtensionManager {
private options: ExtensionManagerOptions = {
schedule: true,
watch: env['EXTENSIONS_AUTO_RELOAD'] && env['NODE_ENV'] !== 'development',
};
private options: ExtensionManagerOptions = defaultOptions;
/**
* Whether or not the extensions have been read from disk and registered into the system
@@ -140,13 +142,10 @@ export class ExtensionManager {
* @param {boolean} options.watch - Whether or not to watch the local extensions folder for changes
*/
public async initialize(options: Partial<ExtensionManagerOptions> = {}): Promise<void> {
if (options.schedule !== undefined) {
this.options.schedule = options.schedule;
}
if (options.watch !== undefined) {
this.options.watch = options.watch;
}
this.options = {
...defaultOptions,
...options,
};
const wasWatcherInitialized = this.watcher !== null;