@@ -5,6 +5,7 @@ import ejs from "#core/ejs";
55import env from "#core/env" ;
66import File from "#core/file" ;
77import FileTree from "#core/file-tree" ;
8+ import { exists } from "#core/fs" ;
89import glob from "#core/glob" ;
910import Markdown from "#core/markdown" ;
1011import ansi from "#core/text/ansi" ;
@@ -166,7 +167,7 @@ export default class Docs {
166167 const fileTree = new FileTree ( ) ;
167168
168169 // generate README.md
169- if ( ! fs . existsSync ( this . locationPath + "/README.md" ) ) {
170+ if ( ! ( await exists ( this . locationPath + "/README.md" ) ) ) {
170171 const readmeTmpl = utils . resolve ( "#resources/templates/docs/README-default.md" , import . meta. url ) ;
171172
172173 if ( this . location !== "/" ) {
@@ -180,7 +181,7 @@ export default class Docs {
180181 else {
181182
182183 // copy root readme
183- if ( fs . existsSync ( this . #package. root + "/README.md" ) ) {
184+ if ( await exists ( this . #package. root + "/README.md" ) ) {
184185 fileTree . add ( {
185186 "path" : "README.md" ,
186187 "buffer" : fs . readFileSync ( this . #package. root + "/README.md" ) ,
@@ -198,7 +199,7 @@ export default class Docs {
198199 }
199200
200201 // generate default sidebar
201- if ( ! fs . existsSync ( this . locationPath + "/_sidebar.md" ) ) {
202+ if ( ! ( await exists ( this . locationPath + "/_sidebar.md" ) ) ) {
202203 fileTree . add ( {
203204 "path" : "_sidebar.md" ,
204205 "buffer" : await ejs . renderFile ( utils . resolve ( "#resources/templates/docs/_sidebar.md" , import . meta. url ) , options ) ,
@@ -288,7 +289,7 @@ export default class Docs {
288289 async #buildReadme ( options ) {
289290 const readmePath = this . locationPath + "/README.md" ;
290291
291- if ( this . location === "/" || options . generateReadme === false || ! fs . existsSync ( readmePath ) ) return ;
292+ if ( this . location === "/" || options . generateReadme === false || ! ( await exists ( readmePath ) ) ) return ;
292293
293294 const template = utils . resolve ( "#resources/templates/docs/README-wrapper.md.ejs" , import . meta. url ) ,
294295 fileTree = new FileTree ( ) ;
0 commit comments