From 1f1accf98941a0f78e6de367d5249211023a5220 Mon Sep 17 00:00:00 2001 From: Yale Date: Sat, 21 Oct 2023 22:43:06 +0800 Subject: [PATCH 1/2] fix(cli) parseTemplatePath doesn't work in windows --- packages/qwik/src/cli/utils/templates.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/qwik/src/cli/utils/templates.ts b/packages/qwik/src/cli/utils/templates.ts index 1acfbfc0c0a..8d922e1ccaa 100644 --- a/packages/qwik/src/cli/utils/templates.ts +++ b/packages/qwik/src/cli/utils/templates.ts @@ -58,7 +58,10 @@ export async function readTemplates(rootDir: string) { } function parseTemplatePath(path: string, type: string) { - const parts = path.split(`/${type}/`); + let parts = path.split(`/${type}/`); + if (parts.length == 1) { + parts = path.split(`\\${type}\\`); + } return { absolute: path, From 3887f0b0209bbc3c07a732d3e196044a6b8d55bb Mon Sep 17 00:00:00 2001 From: Yale Date: Mon, 23 Oct 2023 21:18:19 +0800 Subject: [PATCH 2/2] refactor use path.sep --- packages/qwik/src/cli/utils/templates.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/qwik/src/cli/utils/templates.ts b/packages/qwik/src/cli/utils/templates.ts index 8d922e1ccaa..2ed41a62565 100644 --- a/packages/qwik/src/cli/utils/templates.ts +++ b/packages/qwik/src/cli/utils/templates.ts @@ -1,5 +1,5 @@ import fs from 'node:fs'; -import { join } from 'node:path'; +import { join, sep } from 'node:path'; import type { TemplateSet } from '../types'; import { getFilesDeep } from './utils'; @@ -58,10 +58,7 @@ export async function readTemplates(rootDir: string) { } function parseTemplatePath(path: string, type: string) { - let parts = path.split(`/${type}/`); - if (parts.length == 1) { - parts = path.split(`\\${type}\\`); - } + const parts = path.split(sep + type + sep); return { absolute: path,