From 6f05d4b05afd5cee36f8a685e05982de315e735d Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 8 Oct 2022 11:57:10 +0800 Subject: [PATCH] fix: docs path in windows --- packages/mermaid/src/docs.mts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/mermaid/src/docs.mts b/packages/mermaid/src/docs.mts index 88f052085..72357135d 100644 --- a/packages/mermaid/src/docs.mts +++ b/packages/mermaid/src/docs.mts @@ -203,30 +203,33 @@ const transformHtml = (filename: string) => { copyTransformedContents(filename, !verifyOnly, formattedHTML); }; +const getFilesFromGlobs = async (globs: string[]): Promise => { + return await globby( + globs.map((glob) => glob.replace(/\\/g, '/')), + { + dot: true, + } + ); +}; + /** Main method (entry point) */ (async () => { if (verifyOnly) { console.log('Verifying that all files are in sync with the source files'); } const sourceDirGlob = join('.', SOURCE_DOCS_DIR, '**'); - const includeFilesStartingWithDot = true; + const action = verifyOnly ? 'Verifying' : 'Transforming'; - console.log('Transforming markdown files...'); - const mdFiles = await globby([join(sourceDirGlob, '*.md')], { - dot: includeFilesStartingWithDot, - }); + const mdFiles = await getFilesFromGlobs([join(sourceDirGlob, '*.md')]); + console.log(`${action} ${mdFiles.length} markdown files...`); mdFiles.forEach(transformMarkdown); - console.log('Transforming html files...'); - const htmlFiles = await globby([join(sourceDirGlob, '*.html')], { - dot: includeFilesStartingWithDot, - }); + const htmlFiles = await getFilesFromGlobs([join(sourceDirGlob, '*.html')]); + console.log(`${action} ${htmlFiles.length} html files...`); htmlFiles.forEach(transformHtml); - console.log('Transforming all other files...'); - const otherFiles = await globby([sourceDirGlob, '!**/*.md', '!**/*.html'], { - dot: includeFilesStartingWithDot, - }); + const otherFiles = await getFilesFromGlobs([sourceDirGlob, '!**/*.md', '!**/*.html']); + console.log(`${action} ${otherFiles.length} other files...`); otherFiles.forEach((file: string) => { copyTransformedContents(file, !verifyOnly); // no transformation }); @@ -237,7 +240,7 @@ const transformHtml = (filename: string) => { process.exit(1); } if (git) { - console.log('Adding changes in ${FINAL_DOCS_DIR} folder to git'); + console.log(`Adding changes in ${FINAL_DOCS_DIR} folder to git`); exec('git add docs'); } }