Skip to content

Commit

Permalink
chore: ci cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Oct 16, 2023
1 parent 575424a commit 0d2b173
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions config/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,57 +374,52 @@ let developerDocs = [];
const pathToDocs = path.join(__dirname, '..', 'app', 'views', 'docs');

for (const dir of fs.readdirSync(pathToDocs, { withFileTypes: true })) {
console.log('UTILITY DIRECTORY', dir);
if (!dir.isDirectory()) continue;

// `dir.path` is not available until Node v20.1.0
// if (!dir.path) dir.path = path.join(pathToDocs, dir.name);
dir.path = path.join(pathToDocs, dir.name);
const dirPath = path.join(pathToDocs, dir.name);

console.log('dir.path', dir.path);

if (!fs.existsSync(path.join(dir.path, 'index.pug'))) {
console.error('%s missing index.pug', dir.path);
if (!fs.existsSync(path.join(dirPath, 'index.pug'))) {
console.error('%s missing index.pug', dirPath);
continue;
}

if (!fs.existsSync(path.join(dir.path, 'config.js'))) {
console.error('%s missing config.js', dir.path);
if (!fs.existsSync(path.join(dirPath, 'config.js'))) {
console.error('%s missing config.js', dirPath);
continue;
}

// safeguard
if (dashify(dir.name) !== dir.name) {
console.error(
`${dir.path} is not in slug format ("${dir.name}" should be "${dashify(
`${dirPath} is not in slug format ("${dir.name}" should be "${dashify(
dir.name
)}")`
);
continue;
}

try {
const c = require(path.join(dir.path, 'config.js'));
const c = require(path.join(dirPath, 'config.js'));
c.slug = `/docs/${dir.name}`;

if (!isSANB(c.title)) {
console.error('%s missing config.js title', dir.path);
console.error('%s missing config.js title', dirPath);
continue;
}

if (!isSANB(c.description)) {
console.error('%s missing config.js description', dir.path);
console.error('%s missing config.js description', dirPath);
continue;
}

if (c.published !== true) {
console.error('%s is not yet published', dir.path);
console.error('%s is not yet published', dirPath);
continue;
}

developerDocs.push(c);
} catch {
console.error('%s is missing config.js', dir.path);
console.error('%s is missing config.js', dirPath);
}
}

Expand Down

0 comments on commit 0d2b173

Please sign in to comment.