|
|
@@ -3,15 +3,14 @@ const path = require('path');
|
|
|
const { promisify } = require('util');
|
|
|
const extract = require('./extract');
|
|
|
|
|
|
+// Promisified fs functions
|
|
|
const readdirAsync = promisify(fs.readdir);
|
|
|
const readFileAsync = promisify(fs.readFile);
|
|
|
const writeFileAsync = promisify(fs.writeFile);
|
|
|
|
|
|
-if (!process.env.MD_PATH) {
|
|
|
- console.log('process.env.MD_PATH must be defined');
|
|
|
- process.exit(1);
|
|
|
-}
|
|
|
-const markdownPath = path.join(process.cwd(), process.env.MD_PATH);
|
|
|
+// Source and destination paths
|
|
|
+const markdownPath = path.resolve(__dirname, '../markdown');
|
|
|
+const jsonPath = path.resolve(__dirname, '../../front/src/resources/markdown.json');
|
|
|
|
|
|
async function run(filterFunc) {
|
|
|
const allFiles = await readdirAsync(markdownPath);
|
|
|
@@ -20,7 +19,7 @@ async function run(filterFunc) {
|
|
|
const tutoPath = path.join(markdownPath, tuto);
|
|
|
const buf = await readFileAsync(tutoPath);
|
|
|
const md = buf.toString();
|
|
|
- console.log(md.substr(0, 10));
|
|
|
+ console.log(md.split('\n').shift());
|
|
|
try {
|
|
|
return extract(md);
|
|
|
} catch (err) {
|
|
|
@@ -29,7 +28,7 @@ async function run(filterFunc) {
|
|
|
});
|
|
|
const tutos = await Promise.all(promises);
|
|
|
const json = JSON.stringify(tutos);
|
|
|
- await writeFileAsync('lbac.json', json);
|
|
|
+ await writeFileAsync(jsonPath, json);
|
|
|
process.exit();
|
|
|
}
|
|
|
|