|
@@ -1,5 +1,6 @@
|
1
|
1
|
extern crate clap;
|
2
|
2
|
extern crate comrak;
|
|
3
|
+extern crate fs_extra;
|
3
|
4
|
#[macro_use]
|
4
|
5
|
extern crate lazy_static;
|
5
|
6
|
extern crate regex;
|
|
@@ -8,6 +9,7 @@ extern crate uuid;
|
8
|
9
|
use std::{env, fs};
|
9
|
10
|
|
10
|
11
|
use clap::{App, Arg};
|
|
12
|
+use fs_extra::dir;
|
11
|
13
|
|
12
|
14
|
use post::{parse_post, read_posts_dir};
|
13
|
15
|
use write::{write_post, write_post_listing};
|
|
@@ -57,6 +59,12 @@ fn build() {
|
57
|
59
|
&post_item_template,
|
58
|
60
|
&posts,
|
59
|
61
|
);
|
|
62
|
+
|
|
63
|
+ fs_extra::copy_items(
|
|
64
|
+ &vec![cwd.join("css"), cwd.join("js")],
|
|
65
|
+ cwd.join("public"),
|
|
66
|
+ &dir::CopyOptions::new(),
|
|
67
|
+ ).expect("Couldn't copy css/js directories");
|
60
|
68
|
}
|
61
|
69
|
|
62
|
70
|
fn new(name: &str) {
|
|
@@ -65,11 +73,15 @@ fn new(name: &str) {
|
65
|
73
|
|
66
|
74
|
fs::create_dir(&project_path).expect(&format!("Couldn't create directory '{}'", &name));
|
67
|
75
|
|
68
|
|
- for dir in &["posts", "public", "templates"] {
|
|
76
|
+ for dir in &["posts", "public", "templates", "css", "js"] {
|
69
|
77
|
fs::create_dir(&project_path.join(&dir))
|
70
|
78
|
.expect(&format!("Couldn't create {} directory", &dir));
|
71
|
79
|
}
|
72
|
80
|
|
|
81
|
+ fs::write(project_path.join("css").join("style.css"), "")
|
|
82
|
+ .expect("Couldn't create css/style.css");
|
|
83
|
+ fs::write(project_path.join("js").join("index.js"), "").expect("Couldn't create js/index.js");
|
|
84
|
+
|
73
|
85
|
for file in &["layout", "post_listing", "post", "post_listing_item"] {
|
74
|
86
|
fs::write(
|
75
|
87
|
&project_path
|
|
@@ -141,6 +153,14 @@ mod tests {
|
141
|
153
|
"",
|
142
|
154
|
fs::read_to_string(&project_dir.join("templates").join("post.html")).unwrap()
|
143
|
155
|
);
|
|
156
|
+ assert_eq!(
|
|
157
|
+ "",
|
|
158
|
+ fs::read_to_string(&project_dir.join("css").join("style.css")).unwrap()
|
|
159
|
+ );
|
|
160
|
+ assert_eq!(
|
|
161
|
+ "",
|
|
162
|
+ fs::read_to_string(&project_dir.join("js").join("index.js")).unwrap()
|
|
163
|
+ );
|
144
|
164
|
|
145
|
165
|
fs::remove_dir_all(project_dir).unwrap();
|
146
|
166
|
}
|