Parcourir la source

Gestion du readme

Loquicom il y a 5 ans
Parent
commit
080688acb3
1 fichiers modifiés avec 28 ajouts et 1 suppressions
  1. 28 1
      deploy.js

+ 28 - 1
deploy.js

@@ -1,4 +1,5 @@
 const copydir = require('copy-dir');
+const LineReader = require('n-readlines');
 const file = require('./src/file');
 const deploy = require('./deploy.json');
 
@@ -44,4 +45,30 @@ deploy.programs.forEach(program => {
     let json = JSON.stringify(pckg, null, 4);
     json = json.replace(new RegExp(program.main, 'g'), 'main.js');
     file.put(distPath + '/package.json', json);
-});
+    // Ecriture ReadMe
+    file.put(distPath + '/README.md', readMe(program.part));
+});
+
+// Fonction découpage readme
+function readMe(part) {
+    const liner = new LineReader('./README.md');
+    let data = '';
+    let line = liner.next().toString();
+    while (line !== 'false' && line.indexOf('## Partie ') === -1) {
+        data += '\n' + line;
+        line = liner.next().toString();
+    }
+    while (line !== 'false' && line.indexOf('## Partie ' + part) === -1) {
+        line = liner.next().toString();
+    }
+    data += '\n' + line;
+    line = liner.next().toString();
+    while (line !== 'false' && line.indexOf('## Partie ') === -1) {
+        data += '\n' + line;
+        line = liner.next().toString();
+    }
+    if (line !== 'false') {
+        liner.close();
+    }
+    return data;
+}