|
1 | 1 | import * as nodeUrl from "node:url";
|
| 2 | +import * as nodePath from "node:path"; |
2 | 3 | import * as nodeFsPromises from "node:fs/promises";
|
3 | 4 | import * as nodeUtilTypes from "node:util/types";
|
4 | 5 | import { getModules } from "file-folder-loader";
|
@@ -175,9 +176,10 @@ async function loadEventHandlers(
|
175 | 176 | options?: LoadEventHandlersOptions,
|
176 | 177 | bindEventListenerOverride?: BindEventListenerOverride,
|
177 | 178 | ) {
|
178 |
| - const isValidDir = await isValidDirectory(dirPath); |
| 179 | + const absolutePath = nodePath.resolve(dirPath); |
| 180 | + const isValidDir = await isValidDirectory(absolutePath); |
179 | 181 | if (!isValidDir) {
|
180 |
| - throw new Error(`Invalid event handler directory path: '${dirPath}'. Must be an existent directory.`); |
| 182 | + throw new Error(`Invalid event handler directory path: '${absolutePath}'. Must be an existent accessible directory.`); |
181 | 183 | }
|
182 | 184 | if (!hasAddListenerMethods(eventEmitterLike)) {
|
183 | 185 | throw new Error("Invalid eventEmitterLike instance. Must have EventEmitter methods.");
|
@@ -218,7 +220,7 @@ async function loadEventHandlers(
|
218 | 220 | if (typeof isRecursive !== "boolean") {
|
219 | 221 | throw new Error(`Invalid isRecursive: '${isRecursive}'. Must be a boolean.`);
|
220 | 222 | }
|
221 |
| - const filePaths = await getModules(dirPath, { isRecursive: isRecursive, processMode: importMode }); |
| 223 | + const filePaths = await getModules(absolutePath, { isRecursive: isRecursive, processMode: importMode }); |
222 | 224 | async function loadEventHandler(filePath: string) {
|
223 | 225 | const fileUrlHref = nodeUrl.pathToFileURL(filePath).href;
|
224 | 226 | /**
|
|
0 commit comments