Browse Source

Move css/ and js/ to assets/

master
Dylan Baker 5 years ago
parent
commit
4ce4e68df5
3 changed files with 10 additions and 37 deletions
  1. 2
    0
      Cargo.lock
  2. 3
    7
      src/lib.rs
  3. 5
    30
      tests/integration_test.rs

+ 2
- 0
Cargo.lock View File

@@ -1,3 +1,5 @@
1
+# This file is automatically @generated by Cargo.
2
+# It is not intended for manual editing.
1 3
 [[package]]
2 4
 name = "aho-corasick"
3 5
 version = "0.6.9"

+ 3
- 7
src/lib.rs View File

@@ -100,11 +100,11 @@ pub fn build(include_drafts: bool, cwd: &path::Path) {
100 100
     );
101 101
 
102 102
     fs_extra::copy_items(
103
-        &vec![cwd.join("css"), cwd.join("js")],
103
+        &vec![cwd.join("assets")],
104 104
         cwd.join("public"),
105 105
         &dir::CopyOptions::new(),
106 106
     )
107
-    .expect("Couldn't copy css/js directories");
107
+    .expect("Couldn't copy assets directory");
108 108
 }
109 109
 
110 110
 pub fn new(name: &str, cwd: &path::Path) {
@@ -123,17 +123,13 @@ pub fn new(name: &str, cwd: &path::Path) {
123 123
         "pages",
124 124
         "public",
125 125
         "templates",
126
-        "css",
126
+        "assets",
127 127
         "js",
128 128
     ] {
129 129
         fs::create_dir(&project_path.join(&dir))
130 130
             .expect(&format!("Couldn't create {} directory", &dir));
131 131
     }
132 132
 
133
-    fs::write(project_path.join("css").join("style.css"), "")
134
-        .expect("Couldn't create css/style.css");
135
-    fs::write(project_path.join("js").join("index.js"), "").expect("Couldn't create js/index.js");
136
-
137 133
     let default_layout_template = format!(
138 134
         "<html>
139 135
   <head>

+ 5
- 30
tests/integration_test.rs View File

@@ -13,9 +13,8 @@ fn test_build() {
13 13
     let project_dir = temp_dir.path().join(&uuid);
14 14
 
15 15
     fs::create_dir(&project_dir).unwrap();
16
-    fs::create_dir(&project_dir.join("css")).unwrap();
16
+    fs::create_dir(&project_dir.join("assets")).unwrap();
17 17
     fs::create_dir(&project_dir.join("drafts")).unwrap();
18
-    fs::create_dir(&project_dir.join("js")).unwrap();
19 18
     fs::create_dir(&project_dir.join("pages")).unwrap();
20 19
     fs::create_dir(&project_dir.join("posts")).unwrap();
21 20
     fs::create_dir(&project_dir.join("public")).unwrap();
@@ -23,15 +22,10 @@ fn test_build() {
23 22
     fs::create_dir(&project_dir.join("templates")).unwrap();
24 23
 
25 24
     fs::write(
26
-        project_dir.join("css").join("style.css"),
25
+        project_dir.join("assets").join("style.css"),
27 26
         "body { background: blue; }",
28 27
     )
29 28
     .unwrap();
30
-    fs::write(
31
-        project_dir.join("js").join("index.js"),
32
-        "window.onload = function () { alert() }",
33
-    )
34
-    .unwrap();
35 29
     fs::write(
36 30
         project_dir.join("templates").join("layout.html"),
37 31
         "<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
@@ -112,12 +106,7 @@ fn test_build() {
112 106
 
113 107
     assert_eq!(
114 108
         "body { background: blue; }",
115
-        fs::read_to_string(project_dir.join("public").join("css").join("style.css")).unwrap()
116
-    );
117
-
118
-    assert_eq!(
119
-        "window.onload = function () { alert() }",
120
-        fs::read_to_string(project_dir.join("public").join("js").join("index.js")).unwrap()
109
+        fs::read_to_string(project_dir.join("public").join("assets").join("style.css")).unwrap()
121 110
     );
122 111
 }
123 112
 
@@ -130,9 +119,8 @@ fn test_build_drafts() {
130 119
     fs::create_dir(&project_dir).unwrap();
131 120
     env::set_current_dir(&project_dir).unwrap();
132 121
 
133
-    fs::create_dir(&project_dir.join("css")).unwrap();
122
+    fs::create_dir(&project_dir.join("assets")).unwrap();
134 123
     fs::create_dir(&project_dir.join("drafts")).unwrap();
135
-    fs::create_dir(&project_dir.join("js")).unwrap();
136 124
     fs::create_dir(&project_dir.join("pages")).unwrap();
137 125
     fs::create_dir(&project_dir.join("posts")).unwrap();
138 126
     fs::create_dir(&project_dir.join("public")).unwrap();
@@ -140,15 +128,10 @@ fn test_build_drafts() {
140 128
     fs::create_dir(&project_dir.join("templates")).unwrap();
141 129
 
142 130
     fs::write(
143
-        project_dir.join("css").join("style.css"),
131
+        project_dir.join("assets").join("style.css"),
144 132
         "body { background: blue; }",
145 133
     )
146 134
     .unwrap();
147
-    fs::write(
148
-        project_dir.join("js").join("index.js"),
149
-        "window.onload = function () { alert() }",
150
-    )
151
-    .unwrap();
152 135
     fs::write(
153 136
         project_dir.join("templates").join("layout.html"),
154 137
         "<html><head><title>{{ page_title }}</title></head><body>{{ contents }}</body></html>",
@@ -288,14 +271,6 @@ fn test_new() {
288 271
             .replace("\n", "")
289 272
             .replace("  ", "")
290 273
     );
291
-    assert_eq!(
292
-        "",
293
-        fs::read_to_string(&project_dir.join("css").join("style.css")).unwrap()
294
-    );
295
-    assert_eq!(
296
-        "",
297
-        fs::read_to_string(&project_dir.join("js").join("index.js")).unwrap()
298
-    );
299 274
     assert_eq!(
300 275
         format!("site_name = \"{}\"", &uuid),
301 276
         fs::read_to_string(&project_dir.join("casaubon.toml")).unwrap()

Loading…
Cancel
Save