From 3c8dcbabab2dd86485dfb6d2532bc48a684f5549 Mon Sep 17 00:00:00 2001 From: Natsune Mochizuki Date: Thu, 29 Dec 2022 12:22:29 +0900 Subject: [PATCH] fix(react-email): fix incorrect glob pattern in `email export` under the Windows --- packages/react-email/package.json | 2 ++ packages/react-email/source/commands/exportTemplates.ts | 5 +++-- yarn.lock | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/react-email/package.json b/packages/react-email/package.json index 98ac4155ed..222c9be11b 100644 --- a/packages/react-email/package.json +++ b/packages/react-email/package.json @@ -37,6 +37,7 @@ "esbuild": "0.16.4", "glob": "8.0.3", "log-symbols": "4.1.0", + "normalize-path": "3.0.0", "ora": "5.4.1", "read-pkg": "5.2.0", "shelljs": "0.8.5", @@ -44,6 +45,7 @@ }, "devDependencies": { "@types/node": "18.11.9", + "@types/normalize-path": "3.0.0", "@types/shelljs": "0.8.11", "prettier": "2.7.1", "ts-node": "10.9.1" diff --git a/packages/react-email/source/commands/exportTemplates.ts b/packages/react-email/source/commands/exportTemplates.ts index a45afd029e..eb62c29432 100644 --- a/packages/react-email/source/commands/exportTemplates.ts +++ b/packages/react-email/source/commands/exportTemplates.ts @@ -6,6 +6,7 @@ import logSymbols from 'log-symbols'; import { render } from '@react-email/render'; import { unlinkSync, writeFileSync } from 'fs'; import copy from 'cpy'; +import normalize from 'normalize-path'; import { checkDirectoryExist, CLIENT_EMAILS_PATH } from '../utils'; /* @@ -15,7 +16,7 @@ import { checkDirectoryExist, CLIENT_EMAILS_PATH } from '../utils'; */ export const exportTemplates = async (outDir: string, pretty: boolean) => { const spinner = ora('Preparing files...\n').start(); - const allTemplates = glob.sync(`${CLIENT_EMAILS_PATH}/*.{tsx,jsx}`); + const allTemplates = glob.sync(normalize(`${CLIENT_EMAILS_PATH}/*.{tsx,jsx}`)); esbuild.buildSync({ bundle: true, @@ -25,7 +26,7 @@ export const exportTemplates = async (outDir: string, pretty: boolean) => { outdir: outDir, }); - const allBuiltTemplates = glob.sync(`${outDir}/*.js`, { + const allBuiltTemplates = glob.sync(normalize(`${outDir}/*.js`), { absolute: true, }); diff --git a/yarn.lock b/yarn.lock index b8d76e461e..9fb35b9a05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1285,6 +1285,11 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== +"@types/normalize-path@3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/normalize-path/-/normalize-path-3.0.0.tgz#bb5c46cab77b93350b4cf8d7ff1153f47189ae31" + integrity sha512-Nd8y/5t/7CRakPYiyPzr/IAfYusy1FkcZYFEAcoMZkwpJv2n4Wm+olW+e7xBdHEXhOnWdG9ddbar0gqZWS4x5Q== + "@types/prettier@^2.1.5": version "2.7.1" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.1.tgz#dfd20e2dc35f027cdd6c1908e80a5ddc7499670e" @@ -5449,7 +5454,7 @@ normalize-package-data@^2.5.0: semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-path@^3.0.0, normalize-path@~3.0.0: +normalize-path@3.0.0, normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==