From 00be00501857c9a5b5e59922dd6967c1620f775f Mon Sep 17 00:00:00 2001 From: Josh <37798644+joshuaellis@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:12:18 +0000 Subject: [PATCH] fix: for windows --- packages/core/admin/utils/get-plugins-path.js | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/core/admin/utils/get-plugins-path.js b/packages/core/admin/utils/get-plugins-path.js index 0cd38227ed..a12c030c31 100644 --- a/packages/core/admin/utils/get-plugins-path.js +++ b/packages/core/admin/utils/get-plugins-path.js @@ -1,6 +1,6 @@ 'use strict'; -const { join, resolve } = require('path'); +const { join, resolve, sep, posix } = require('path'); const fs = require('fs-extra'); // eslint-disable-next-line import/no-extraneous-dependencies const glob = require('glob'); @@ -8,8 +8,22 @@ const glob = require('glob'); // Only for dev environement const getPluginsPath = () => { const rootPath = resolve(__dirname, '..', join('..', '..', '..', 'packages')); - const corePath = join(rootPath, 'core', '*'); - const pluginsPath = join(rootPath, 'plugins', '*'); + /** + * So `glob` only supports '/' as a path separator, so we need to replace + * the path separator for the current OS with '/'. e.g. on windows it's `\`. + * + * see https://github.com/isaacs/node-glob/#windows for more information + * + * and see https://github.com/isaacs/node-glob/issues/467#issuecomment-1114240501 for the recommended fix. + */ + let corePath = join(rootPath, 'core', '*'); + let pluginsPath = join(rootPath, 'plugins', '*'); + + if (process.platform === 'win32') { + corePath = corePath.split(sep).join(posix.sep); + pluginsPath = pluginsPath.split(sep).join(posix.sep); + } + const corePackageDirs = glob.sync(corePath); const pluginsPackageDirs = glob.sync(pluginsPath);