From 8afaaf162dd8a2e69d3fda0d0f8b3443a698e2df Mon Sep 17 00:00:00 2001 From: zdm Date: Mon, 15 Apr 2024 22:51:36 +0300 Subject: [PATCH] fix: docs --- lib/package/docs.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/package/docs.js b/lib/package/docs.js index ec030d45..8ab87681 100644 --- a/lib/package/docs.js +++ b/lib/package/docs.js @@ -22,21 +22,24 @@ export default class Docs { return this.#rootPackage; } + get kication () { + return this.#rootPackage.cliConfig.docs?.location; + } + get locationPath () { if ( !this.#rootPackage.cliConfig.docs ) { return null; } - else if ( !this.#rootPackage.cliConfig.docs.location ) { + else if ( !this.location ) { return this.#rootPackage.root; } else { - return this.#rootPackage.root + "/" + this.#rootPackage.cliConfig.docs.location; + return this.#rootPackage.root + "/" + this.location; } } - // XXX isExists -> isEnabled get isExists () { - return !!this.#rootPackage.cliConfig.docs; + return !!( this.locationPath && fs.existsSync( this.locationPath ) ); } async init () { @@ -106,7 +109,7 @@ export default class Docs { if ( !fs.existsSync( this.locationPath + "/README.md" ) ) { const readmeTmpl = utils.resolve( "#resources/templates/docs/README.md", import.meta.url ); - if ( options.location ) { + if ( this.location ) { // default readme fileTree.add( { "path": "README.md", "buffer": await ejs.renderFile( readmeTmpl, options ) } ); @@ -204,7 +207,7 @@ export default class Docs { async #buildReadme ( options ) { const readmePath = this.locationPath + "/README.md"; - if ( options.location || options.generateReadme === false || !fs.existsSync( readmePath ) ) return; + if ( this.location || options.generateReadme === false || !fs.existsSync( readmePath ) ) return; const template = utils.resolve( "#resources/templates/docs/README.main.md.ejs", import.meta.url ), fileTree = new FileTree(); @@ -288,7 +291,7 @@ export default class Docs { async #initGitHubPages ( options ) { const branch = "main", - path = options.location ? "/" : "/" + options.location; + path = this.location ? "/" : "/" + options.location; process.stdout.write( `Initializing GitHub pages ... ` );