chore(rocket-preset-extend-lion-docs): make it work on windows

This commit is contained in:
Thomas Allmer 2022-11-11 13:01:19 +01:00 committed by Thomas Allmer
parent 4708fe9462
commit 0764d2ce92
3 changed files with 12 additions and 8 deletions

View file

@ -28,12 +28,16 @@ export async function getPublicApiOfPkg(pkgJsonPath) {
pkgExports[pkgExportDefinition].default ||
pkgExports[pkgExportDefinition].module ||
pkgExports[pkgExportDefinition];
const entryPointFilePath = path.join(pkgPath, pkgExportPath);
const entryPointFilePath = path.join(pkgPath, pkgExportPath.split('/').join(path.sep));
if (glob.hasMagic(entryPointFilePath)) {
const globifiedEntryPointFilePath = entryPointFilePath.replace(/\*/, '**');
const globifiedEntryPointFilePath = entryPointFilePath
.split(path.sep)
.join('/')
.replace(/\*/, '**');
if (glob.hasMagic(globifiedEntryPointFilePath)) {
for (const entryPointFile of glob.sync(globifiedEntryPointFilePath, { nodir: true })) {
const fullPkgExportPath = path.join(pkgPath, pkgExportPath);
const fullPkgExportPath = path.join(pkgPath, pkgExportPath).split(path.sep).join('/');
const reg = new RegExp(`^${fullPkgExportPath.replace('*', '(.*)')}$`);
const match = reg.exec(entryPointFile);
if (match) {
@ -48,7 +52,7 @@ export async function getPublicApiOfPkg(pkgJsonPath) {
name: pkgEntryPoint,
namePath: pkgEntryPointPath,
exports,
path: entryPointFile,
path: entryPointFile.split('/').join(path.sep),
});
}
}

View file

@ -21,7 +21,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
* @returns
*/
async function execute(input, options = {}) {
const nodeModulesDir = path.join(__dirname, input);
const nodeModulesDir = path.join(__dirname, input.split('/').join(path.sep));
const result = await generateExtendDocsConfig({
// used tsc version does not recognize optional jsdoc params

View file

@ -13,13 +13,13 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
* @returns
*/
async function execute(input) {
const pkgJsonPath = path.join(__dirname, input);
const pkgJsonPath = path.join(__dirname, input.split('/').join(path.sep));
const result = await getPublicApiOfPkg(pkgJsonPath);
return {
...result,
entryPoints: result.entryPoints.map(ep => ({
...ep,
path: ep.path.replace(__dirname, 'abs::'),
path: ep.path.replace(__dirname, 'abs::').replace(/\\/g, '/'),
})),
};
}