fix(medusa): Normalize subscriber paths (#5703)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): Exclude subscribers correctly on Windows
|
||||||
@@ -579,8 +579,6 @@ async function registerSubscribers(
|
|||||||
container: MedusaContainer,
|
container: MedusaContainer,
|
||||||
activityId: string
|
activityId: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const exclude: string[] = []
|
|
||||||
|
|
||||||
const loadedFiles = await new SubscriberLoader(
|
const loadedFiles = await new SubscriberLoader(
|
||||||
path.join(pluginDetails.resolve, "subscribers"),
|
path.join(pluginDetails.resolve, "subscribers"),
|
||||||
container,
|
container,
|
||||||
@@ -591,11 +589,12 @@ async function registerSubscribers(
|
|||||||
/**
|
/**
|
||||||
* Exclude any files that have already been loaded by the subscriber loader
|
* Exclude any files that have already been loaded by the subscriber loader
|
||||||
*/
|
*/
|
||||||
exclude.push(...(loadedFiles ?? []))
|
const normalizedLoadedFiles =
|
||||||
|
loadedFiles?.map((file) => file.replace(/\\/g, "/")) ?? []
|
||||||
|
|
||||||
const files = glob.sync(`${pluginDetails.resolve}/subscribers/*.js`, {})
|
const files = glob.sync(`${pluginDetails.resolve}/subscribers/*.js`, {})
|
||||||
files
|
files
|
||||||
.filter((file) => !exclude.includes(file))
|
.filter((file) => !normalizedLoadedFiles.includes(file))
|
||||||
.forEach((fn) => {
|
.forEach((fn) => {
|
||||||
const loaded = require(fn).default
|
const loaded = require(fn).default
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user