1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-02-24 01:22:26 +01:00
BezierInfo-2/tools/build/get-all-chapter-files.js
2020-08-04 11:06:54 -07:00

30 lines
726 B
JavaScript

const fs = require("fs-extra");
const glob = require("glob");
const path = require("path");
// make sure we know what our base location is
const BASEDIR = path.join(__dirname, "..", "..");
/**
* ...docs go here...
*/
module.exports = function getAllChapterFiles() {
return new Promise((resolve, reject) => {
glob(path.join(BASEDIR, `chapters/**/content*md`), (err, files) => {
if (err) reject(err);
const locales = {};
files.forEach((file) => {
let locale = file.match(/content\.([^.]+)\.md/)[1];
if (!locales[locale]) {
locales[locale] = [];
}
locales[locale].push(file);
});
resolve(locales);
});
});
}