11import fs from 'fs/promises' ;
2+ import pathlib from 'path' ;
23import type { BuildResult , ResolvedBundle , ResultType } from '@sourceacademy/modules-repotools/types' ;
34import { mapAsync } from '@sourceacademy/modules-repotools/utils' ;
45import * as td from 'typedoc' ;
@@ -22,7 +23,7 @@ export async function buildSingleBundleDocs(bundle: ResolvedBundle, outDir: stri
2223 } ;
2324 }
2425
25- await app . generateJson ( project , ` ${ bundle . directory } / dist/ docs.json` ) ;
26+ await app . generateJson ( project , pathlib . join ( bundle . directory , ' dist' , ' docs.json' ) ) ;
2627
2728 if ( app . logger . hasErrors ( ) ) {
2829 return {
@@ -33,7 +34,7 @@ export async function buildSingleBundleDocs(bundle: ResolvedBundle, outDir: stri
3334 } ;
3435 }
3536
36- await fs . mkdir ( ` ${ outDir } / jsons` , { recursive : true } ) ;
37+ await fs . mkdir ( pathlib . join ( outDir , ' jsons' ) , { recursive : true } ) ;
3738 return buildJson ( bundle , outDir , project ) ;
3839}
3940
@@ -45,7 +46,7 @@ type BuildHtmlResult = ResultType;
4546export async function buildHtml ( bundles : Record < string , ResolvedBundle > , outDir : string , logLevel : td . LogLevel ) : Promise < BuildHtmlResult > {
4647 const jsonStats = await mapAsync ( Object . values ( bundles ) , async ( { name, directory } ) => {
4748 try {
48- const stats = await fs . stat ( ` ${ directory } / dist/ docs.json` ) ;
49+ const stats = await fs . stat ( pathlib . join ( directory , ' dist' , ' docs.json' ) ) ;
4950 return stats . isFile ( ) ? undefined : name ;
5051 } catch {
5152 return name ;
@@ -71,7 +72,7 @@ export async function buildHtml(bundles: Record<string, ResolvedBundle>, outDir:
7172 } ;
7273 }
7374
74- await app . generateDocs ( project , ` ${ outDir } / documentation` ) ;
75+ await app . generateDocs ( project , pathlib . join ( outDir , ' documentation' ) ) ;
7576 if ( app . logger . hasErrors ( ) ) {
7677 return {
7778 severity : 'error' ,
0 commit comments