diff --git a/.changeset/chatty-laws-switch.md b/.changeset/chatty-laws-switch.md new file mode 100644 index 0000000000..12b8be57be --- /dev/null +++ b/.changeset/chatty-laws-switch.md @@ -0,0 +1,5 @@ +--- +'@directus/api': patch +--- + +Fixed extension reloading and schedule hooks when using the cli to start Directus diff --git a/api/src/extensions/manager.ts b/api/src/extensions/manager.ts index 4ef63b7da4..5067e5e4f2 100644 --- a/api/src/extensions/manager.ts +++ b/api/src/extensions/manager.ts @@ -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 = {}): Promise { - 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;