Merge pull request #15140 from strapi/fix/window-build-errors

This commit is contained in:
Josh 2022-12-12 08:35:30 +00:00 committed by GitHub
commit 45831f30f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);