Merge pull request #3605 from arpansaha13/sidv/fixWindowsPath

Fix windows paths for `docs:build`
This commit is contained in:
Sidharth Vinod
2022-10-13 12:59:07 +05:30
committed by GitHub

View File

@@ -35,7 +35,7 @@ import { exec } from 'child_process';
import { globby } from 'globby'; import { globby } from 'globby';
import { JSDOM } from 'jsdom'; import { JSDOM } from 'jsdom';
import type { Code, Root } from 'mdast'; import type { Code, Root } from 'mdast';
import { join, dirname } from 'path'; import { posix, dirname } from 'path';
import prettier from 'prettier'; import prettier from 'prettier';
import { remark } from 'remark'; import { remark } from 'remark';
// @ts-ignore No typescript declaration file // @ts-ignore No typescript declaration file
@@ -210,30 +210,28 @@ const transformHtml = (filename: string) => {
copyTransformedContents(filename, !verifyOnly, formattedHTML); copyTransformedContents(filename, !verifyOnly, formattedHTML);
}; };
const getFilesFromGlobs = async (globs: string[]): Promise<string[]> => {
return await globby(globs, { dot: true });
};
/** Main method (entry point) */ /** Main method (entry point) */
(async () => { (async () => {
if (verifyOnly) { if (verifyOnly) {
console.log('Verifying that all files are in sync with the source files'); console.log('Verifying that all files are in sync with the source files');
} }
const sourceDirGlob = join('.', SOURCE_DOCS_DIR, '**'); const sourceDirGlob = posix.join('.', SOURCE_DOCS_DIR, '**');
const includeFilesStartingWithDot = true; const action = verifyOnly ? 'Verifying' : 'Transforming';
console.log('Transforming markdown files...'); const mdFiles = await getFilesFromGlobs([posix.join(sourceDirGlob, '*.md')]);
const mdFiles = await globby([join(sourceDirGlob, '*.md')], { console.log(`${action} ${mdFiles.length} markdown files...`);
dot: includeFilesStartingWithDot,
});
mdFiles.forEach(transformMarkdown); mdFiles.forEach(transformMarkdown);
console.log('Transforming html files...'); const htmlFiles = await getFilesFromGlobs([posix.join(sourceDirGlob, '*.html')]);
const htmlFiles = await globby([join(sourceDirGlob, '*.html')], { console.log(`${action} ${htmlFiles.length} html files...`);
dot: includeFilesStartingWithDot,
});
htmlFiles.forEach(transformHtml); htmlFiles.forEach(transformHtml);
console.log('Transforming all other files...'); const otherFiles = await getFilesFromGlobs([sourceDirGlob, '!**/*.md', '!**/*.html']);
const otherFiles = await globby([sourceDirGlob, '!**/*.md', '!**/*.html'], { console.log(`${action} ${otherFiles.length} other files...`);
dot: includeFilesStartingWithDot,
});
otherFiles.forEach((file: string) => { otherFiles.forEach((file: string) => {
copyTransformedContents(file, !verifyOnly); // no transformation copyTransformedContents(file, !verifyOnly); // no transformation
}); });
@@ -244,7 +242,7 @@ const transformHtml = (filename: string) => {
process.exit(1); process.exit(1);
} }
if (git) { 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'); exec('git add docs');
} }
} }