Forráskód Böngészése

It's fucked but, anyway...

Benoît Hubert 6 éve
szülő
commit
6fbfdf9c93

+ 0 - 4
front/src/tmp/2. Spécificités de JS.md

@@ -1,4 +0,0 @@
-Quelques-unes des caractéristiques de JavaScript :
-* C'est un langage de **script**, dynamique.
-* Il est **interprété**, contrairement à Java qui est compilé.
-* 

+ 0 - 16
front/src/tmp/3pouet.md

@@ -1,16 +0,0 @@
-##### Hello World!
-
-Dans `empty.html`, ajoute ceci, sous la section "SCRIPTS" :
-```html      
-<script>
-alert("Hello World!");
-</script>
-```
-
-Puis recharge. Tu as forcément déjà vu ce genre de "popup".
-
-&Ccedil;a a le mérite d'exister, même si c'est pas vraiment le top en matière d'UX !
-
-##### Les variables en JavaScript
-
-Tu connais Java ! Tu sais donc qu'en Java, les variables sont **typées**.

+ 6 - 7
tutorial/md-sections-tool/extractAll.js

@@ -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();
 }
 

tutorial/md-sections-tool/package-lock.json → tutorial/package-lock.json


+ 2 - 1
tutorial/md-sections-tool/package.json

@@ -2,9 +2,10 @@
   "name": "md-sections-tool",
   "version": "1.0.0",
   "description": "",
-  "main": "extract.js",
+  "main": "md-sections-tool/extractAll.js",
   "scripts": {
     "test": "npx mocha --exit --timeout 10000 test/**/*.js",
+    "build": "node md-sections-tool/extractAll.js",
     "lint": "npx eslint --fix src/"
   },
   "keywords": [],