Skip to content

Commit

Permalink
fix: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Apr 15, 2024
1 parent 8544bae commit 8afaaf1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/package/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 ) } );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 ... ` );

Expand Down

0 comments on commit 8afaaf1

Please sign in to comment.