@@ -9,7 +9,8 @@ const fg = require("fast-glob");
9
9
const write = require ( "write" ) ;
10
10
const ora = require ( "ora" ) ;
11
11
const chalk = require ( "chalk" ) ;
12
- const fs = require ( "fs" ) ;
12
+ const fse = require ( "fs-extra" ) ;
13
+
13
14
const resolve = util . resolve ;
14
15
15
16
module . exports = function (
@@ -27,7 +28,8 @@ module.exports = function(
27
28
const indexFile = resolve ( path , indexName || "index.html" ) ;
28
29
const render = new Renderer ( config ) ;
29
30
const files = fg . sync ( "**/*.md" , {
30
- cwd : path
31
+ cwd : path ,
32
+ ignore : [ "_*" ]
31
33
} ) ;
32
34
let app ;
33
35
const spinner = ora ( ) ;
@@ -43,23 +45,24 @@ module.exports = function(
43
45
for ( const file of files ) {
44
46
const res = await render . render ( file ) ;
45
47
queue . push ( res ) ;
46
- spinner . text = "Rendering " + file ;
48
+ console . log ( "Rendering " + file ) ;
47
49
}
48
50
return queue ;
49
51
} )
50
52
. then ( data => {
51
- // 保存文件
53
+ // save file
52
54
return Promise . all (
53
55
data . map ( ( { url, content, path } ) => {
54
56
const filePath = url
55
57
. replace ( / R E A D M E \. m d $ / , "index.html" )
56
58
. replace ( / \. m d $ / , ".html" ) ;
57
- spinner . text = `Rendering ${ url } ` ;
58
59
write ( resolve ( util . cwd ( ) , dest , filePath ) , content ) ;
59
- fs . copyFileSync ( path , resolve ( util . cwd ( ) , dest , url ) ) ;
60
60
} )
61
61
) ;
62
62
} )
63
+ . then ( ( ) => {
64
+ return fse . copy ( path , dest ) ;
65
+ } )
63
66
. then ( ( ) => {
64
67
spinner . succeed ( `Success! Generate static files at ${ chalk . green ( dest ) } ` ) ;
65
68
app && app . close ( ) ;
0 commit comments