Skip to content

Commit

Permalink
fix: use gitignore template
Browse files Browse the repository at this point in the history
Fix #138
  • Loading branch information
filipesilva committed Oct 4, 2020
1 parent bdc80d1 commit 2196c2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/create_cljs_app/template.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require [clojure.string :refer [replace]]
["path" :refer [dirname join]]
["fs" :refer
[copyFileSync mkdirSync readdirSync readFileSync statSync writeFileSync]]))
[copyFileSync mkdirSync readdirSync readFileSync statSync writeFileSync renameSync]]))

(def template-dir
"Path there template files are."
Expand Down Expand Up @@ -69,6 +69,13 @@ Will likely need to be replaced with a proper templating library."
(copy-template from-abs to-abs template-values)
(copyFileSync from-abs to-abs))))

(defn- rename-file
[from to path]
(let [from-abs (join path from)
to-abs (join path to)]
(mkdirSync (dirname to-abs) #js {:recursive true})
(renameSync from-abs to-abs)))

(defn copy-files
"Copy files from one directory to another, preserving folder structure."
[files from to template-values-map]
Expand All @@ -80,4 +87,5 @@ Will likely need to be replaced with a proper templating library."
(copy-files (list-files template-dir template-ignores)
template-dir
app-path
(get-template-values-map name commands)))
(get-template-values-map name commands))
(rename-file "gitignore" ".gitignore" app-path))
2 changes: 2 additions & 0 deletions src/e2e/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
(is (not (existsSync "./.shadow-cljs")))
(is (not (existsSync "./out")))
(is (not (existsSync "./public/js"))))
(testing "Copies .gitignore"
(is (existsSync "./.gitignore")))
(testing "Used template values"
(is (not (fileIncludes "./package.json" "__NAME__")))
(is (not (fileIncludes "./public/index.html" "__NAME__")))
Expand Down
File renamed without changes.

0 comments on commit 2196c2c

Please sign in to comment.