|
|
|
@ -34,6 +34,7 @@ export default class Plugin extends Updatable {
|
|
|
|
|
this._watcherEnabled = null;
|
|
|
|
|
this._watcher = {};
|
|
|
|
|
this._labels = [ 'Plugin', this.manifest?.name || this.constructor?.name ];
|
|
|
|
|
this._registerSections();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -314,7 +315,6 @@ export default class Plugin extends Updatable {
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
await this._registerSettings();
|
|
|
|
|
await this._registerSections();
|
|
|
|
|
} else {
|
|
|
|
|
this.warn(`${toTitleCase(this.type)} has no "start" method!`);
|
|
|
|
|
}
|
|
|
|
@ -377,41 +377,65 @@ export default class Plugin extends Updatable {
|
|
|
|
|
*/
|
|
|
|
|
async _registerSections () {
|
|
|
|
|
try {
|
|
|
|
|
[ 'readme', 'changelog' ].forEach(section => {
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
let sectionPath;
|
|
|
|
|
if (this.sections && !this.sections[section]) {
|
|
|
|
|
if (this.manifest?.sections && this.manifest.sections[section]) {
|
|
|
|
|
if (existsSync(join(this.path, this.manifest.sections[section]))) {
|
|
|
|
|
sectionPath = join(this.path, this.manifest.sections[section]);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @todo Possibly allow any case for these file names.
|
|
|
|
|
*/
|
|
|
|
|
} else if (existsSync(join(this.path, `${section.toUpperCase()}.md`))) {
|
|
|
|
|
sectionPath = join(this.path, `${section.toUpperCase()}.md`);
|
|
|
|
|
} else if (existsSync(join(this.path, section.toUpperCase()))) {
|
|
|
|
|
sectionPath = join(this.path, section.toUpperCase());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sectionPath) {
|
|
|
|
|
this.sections[section] = readFileSync(sectionPath, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
let changelogPath;
|
|
|
|
|
if (this.type !== 'builtin') {
|
|
|
|
|
if (!this.sections.changelog) {
|
|
|
|
|
if (this.manifest?.sections?.changelog) {
|
|
|
|
|
if (existsSync(join(this.path, this.manifest.sections.changelog))) {
|
|
|
|
|
changelogPath = join(this.path, this.manifest.sections.changelog);
|
|
|
|
|
}
|
|
|
|
|
} else if (existsSync(join(this.path, 'CHANGELOG.md'))) {
|
|
|
|
|
changelogPath = join(this.path, 'CHANGELOG.md');
|
|
|
|
|
} else if (existsSync(join(this.path, 'CHANGELOG'))) {
|
|
|
|
|
changelogPath = join(this.path, 'CHANGELOG');
|
|
|
|
|
if (!this.sections.changelog) {
|
|
|
|
|
if (this.manifest?.sections?.changelog) {
|
|
|
|
|
if (existsSync(join(this.path, this.manifest.sections.changelog))) {
|
|
|
|
|
changelogPath = join(this.path, this.manifest.sections.changelog);
|
|
|
|
|
}
|
|
|
|
|
} else if (existsSync(join(this.path, 'CHANGELOG.md'))) {
|
|
|
|
|
changelogPath = join(this.path, 'CHANGELOG.md');
|
|
|
|
|
} else if (existsSync(join(this.path, 'CHANGELOG'))) {
|
|
|
|
|
changelogPath = join(this.path, 'CHANGELOG');
|
|
|
|
|
}
|
|
|
|
|
if (changelogPath) {
|
|
|
|
|
this.sections.changelog = readFileSync(changelogPath, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (changelogPath) {
|
|
|
|
|
this.sections.changelog = readFileSync(changelogPath, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let readmePath;
|
|
|
|
|
if (!this.sections.overview) {
|
|
|
|
|
if (this.manifest?.sections?.overview) {
|
|
|
|
|
if (existsSync(join(this.path, this.manifest.sections.overview))) {
|
|
|
|
|
readmePath = join(this.path, this.manifest.sections.overview);
|
|
|
|
|
}
|
|
|
|
|
} else if (existsSync(join(this.path, 'README.md'))) {
|
|
|
|
|
readmePath = join(this.path, 'README.md');
|
|
|
|
|
} else if (existsSync(join(this.path, 'README'))) {
|
|
|
|
|
readmePath = join(this.path, 'README');
|
|
|
|
|
let readmePath;
|
|
|
|
|
if (!this.sections.overview) {
|
|
|
|
|
if (this.manifest?.sections?.overview) {
|
|
|
|
|
if (existsSync(join(this.path, this.manifest.sections.overview))) {
|
|
|
|
|
readmePath = join(this.path, this.manifest.sections.overview);
|
|
|
|
|
}
|
|
|
|
|
} else if (existsSync(join(this.path, 'README.md'))) {
|
|
|
|
|
readmePath = join(this.path, 'README.md');
|
|
|
|
|
} else if (existsSync(join(this.path, 'README'))) {
|
|
|
|
|
readmePath = join(this.path, 'README');
|
|
|
|
|
}
|
|
|
|
|
if (readmePath) {
|
|
|
|
|
this.sections.overview = readFileSync(readmePath, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (readmePath) {
|
|
|
|
|
this.sections.overview = readFileSync(readmePath, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return this.error(err);
|
|
|
|
|