Skip to content

Commit

Permalink
upd: mdToVue reset
Browse files Browse the repository at this point in the history
  • Loading branch information
richard1015 committed Feb 24, 2020
1 parent 286378a commit 047202f
Showing 1 changed file with 33 additions and 94 deletions.
127 changes: 33 additions & 94 deletions scripts/mdToVue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ let { version } = require("../package.json");
let marked = require('marked');
let contrast = require('./contrast');
let rimraf = require("rimraf");
let Chokidar = require('chokidar');
if (!marked) {
console.log('you need npm i marked -D!');
}
Expand Down Expand Up @@ -34,7 +33,6 @@ class mdVue{
_that.needHandleFiles = res;
_that.ishasOutFile(_that.options.output).then(res=>{
_that.star();
_that.filelisten()
});
})
})
Expand All @@ -61,35 +59,6 @@ class mdVue{

}
apply(){}
filelisten(){
let _that = this;
let watcher = Chokidar.watch(_that.options.entry,{
persistent: true,
usePolling: true,
});
let log = console.dir.bind(console);
let watchAction = function({event, eventPath}){
// 这里进行文件更改后的操作
// fileReadStar(eventPath,(res)=>{
// createdFile(param.output + res.mdName + '.vue', res.html, param.needCode)
// })
console.log(path.join(__dirname,JSON.stringify(eventPath)))
_that.vueDesWrite(eventPath)
// "d:\workplace\nutui\docs\international.md"
// _that.read(eventPath).then(res=>{
// _that.headHandle();
// _that.markHandle();
// let html = _that.marked(res);
// _that.write({
// outsrc:_that.options.output,
// name:fileName + '.vue',
// html:html
// });
// })
}
watcher.on('change', path => watchAction({event: 'change', eventPath: path}))
.on('unlink', path => watchAction({event: 'remove', eventPath: path}));
}
star(){
let _that = this;
hashElement(_that.options.entry, {
Expand All @@ -99,73 +68,43 @@ class mdVue{
}).then(hash => {

nodeFilelist.read([_that.options.entry],{"ext":'md'}, res => {
res.map((item,index) =>{
_that.vueDesWrite(item.path)
// let fileSplits = item.path.split(path.sep);
// let fileName = fileSplits.pop();
// if(_that.isDoc(fileName)){
// fileName = fileSplits.pop();
// }else{
// fileName = fileName.replace(/\.md/,'');
// }
// if(_that.needHandleFiles[fileName]){
// // _that.read(item.path).then(res=>{
// // _that.headHandle();
// // _that.markHandle();
// // let html = _that.marked(res);
// // _that.write({
// // outsrc:_that.options.output,
// // name:fileName + '.vue',
// // html:html
// // });
// // })
// }
// _that.read(item.path).then(res=>{
// _that.headHandle();
// _that.markHandle();
// let html = _that.marked(res);
// _that.write({
// outsrc:_that.options.output,
// name:fileName + '.vue',
// html:html
// });
// })
res.map((item,index) =>{
if(index == 30){
debugger
}
let fileSplits = item.path.split(path.sep);
let fileName = fileSplits.pop();
if(_that.isDoc(fileName)){
fileName = fileSplits.pop();
}else{
fileName = fileName.replace(/\.md/,'');
}
if(_that.needHandleFiles[fileName]){
// _that.read(item.path).then(res=>{
// _that.headHandle();
// _that.markHandle();
// let html = _that.marked(res);
// _that.write({
// outsrc:_that.options.output,
// name:fileName + '.vue',
// html:html
// });
// })
}
_that.read(item.path).then(res=>{
_that.headHandle();
_that.markHandle();
let html = _that.marked(res);
_that.write({
outsrc:_that.options.output,
name:fileName + '.vue',
html:html
});
})
});
});
})
}
vueDesWrite(getpath){
let _that = this;
let fileSplits = getpath.split(path.sep);
let fileName = fileSplits.pop();
if(_that.isDoc(fileName)){
fileName = fileSplits.pop();
}else{
fileName = fileName.replace(/\.md/,'');
}
if(_that.needHandleFiles[fileName]){
// _that.read(item.path).then(res=>{
// _that.headHandle();
// _that.markHandle();
// let html = _that.marked(res);
// _that.write({
// outsrc:_that.options.output,
// name:fileName + '.vue',
// html:html
// });
// })
}
_that.read(getpath).then(res=>{
_that.headHandle();
_that.markHandle();
let html = _that.marked(res);
_that.write({
outsrc:_that.options.output,
name:fileName + '.vue',
html:html
});
})
}
isDoc(name){
return (name == "doc.md") ? true : false;
}
Expand Down

0 comments on commit 047202f

Please sign in to comment.