From 07f9d0d406dda4ec25a6d8be2f8c3e4f6ed4f886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vy=C4=8D=C3=ADtal?= Date: Sun, 12 Apr 2020 19:36:22 +0200 Subject: [PATCH] fix(gen-rollup-conf): fix globbing issues on Windows (#107) Windows separators interfere with escaping. For this reason they decided to use POSIX separators everywhere (they work on Windows by the way). We don't use escaping at the moment so it's fine to just replace all escapes (aka Windows separators) by POSIX separators. --- .../generate-rollup-configuration/index.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/module/generate-rollup-configuration/index.ts b/src/module/generate-rollup-configuration/index.ts index 0c77a7699..5c9ec6991 100644 --- a/src/module/generate-rollup-configuration/index.ts +++ b/src/module/generate-rollup-configuration/index.ts @@ -10,8 +10,8 @@ import postcssPlugin from "rollup-plugin-postcss"; import stripPlugin from "@rollup/plugin-strip"; import typescriptPlugin from "rollup-plugin-typescript2"; import { generateHeader } from "../header"; -import { join, resolve } from "path"; -import { sync as globby } from "globby"; +import { join, resolve, sep } from "path"; +import { sync as rawGlobby } from "globby"; import { terser as terserPlugin } from "rollup-plugin-terser"; import { config as chaiConfig, @@ -29,6 +29,17 @@ const VIS_DEBUG = ["1", "true", "y", "yes"].includes( process.env["VIS_DEBUG"] || "false" ); +/** + * Simple glob with workaround for non-posix paths. + * + * @param pattern - Single glob pattern. + * + * @returns Globbed paths. + */ +function glob(pattern: string): ReturnType { + return rawGlobby(sep === "\\" ? pattern.replace(/\\/g, "/") : pattern); +} + export interface GRCOptions { /** * Where to look for files when inlining assets into CSS. @@ -400,7 +411,7 @@ export function generateRollupConfiguration( "standalone" ].map((name): string => { const filenameGlob = `entry-${name.toLowerCase()}.{js,ts}`; - const files = globby(resolve(entryPoint, filenameGlob)); + const files = glob(resolve(entryPoint, filenameGlob)); validate((expect): void => { expect(