forked from javascript-tutorial/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrateTutorial.js
More file actions
executable file
·46 lines (31 loc) · 1.12 KB
/
migrateTutorial.js
File metadata and controls
executable file
·46 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
var fs = require('fs');
var fse = require('fs-extra');
var co = require('co');
var path = require('path');
var gutil = require('gulp-util');
var glob = require('glob');
var dataUtil = require('lib/dataUtil');
var mongoose = require('lib/mongoose');
var projectRoot = require('config').projectRoot;
var migrate = require('markit/migrate');
module.exports = function() {
return function() {
return co(function*() {
let entities = glob.sync('/js/javascript-tutorial/**/{task,article,solution}.md');
//entities = ['/js/javascript-tutorial/1-js/2-first-steps/17-function-basics/article.md'];
for (var i = 0; i < entities.length; i++) {
var entityPath = entities[i];
console.log('----------->', entityPath);
let migration = migrate(fs.readFileSync(entityPath, 'utf-8'));
let text = migration.text;
let head = migration.head;
console.log(entityPath, head, text, "\n\n\n\n\n");
fs.writeFileSync(entityPath, text);
if (head.trim()) {
fs.writeFileSync(path.dirname(entityPath) + '/head.html', head);
}
}
});
};
};