Include --compass when it is available
This commit is contained in:
parent
4e45a92f92
commit
7595cbcf70
1 changed files with 24 additions and 11 deletions
|
@ -1,13 +1,23 @@
|
||||||
(ns cryogen-core.sass
|
(ns cryogen-core.sass
|
||||||
(:require [clojure.java.shell :refer [sh]]
|
(:require [clojure.java.shell :as shell]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[cryogen-core.io :refer [ignore match-re-filter]]))
|
[cryogen-core.io :refer [ignore match-re-filter]]))
|
||||||
|
|
||||||
|
(defmacro sh
|
||||||
|
[& args]
|
||||||
|
(let [valid-args (remove nil? args)]
|
||||||
|
`(shell/sh ~@valid-args)))
|
||||||
|
|
||||||
(defn sass-installed?
|
(defn sass-installed?
|
||||||
"Checks for the installation of Sass."
|
"Checks for the installation of Sass."
|
||||||
[]
|
[]
|
||||||
(= 0 (:exit (sh "sass" "--version"))))
|
(= 0 (:exit (sh "sass" "--version"))))
|
||||||
|
|
||||||
|
(defn compass-installed?
|
||||||
|
"Checks for the installation of Compass."
|
||||||
|
[]
|
||||||
|
(= 0 (:exit (sh "compass" "--version"))))
|
||||||
|
|
||||||
(defn find-sass-files
|
(defn find-sass-files
|
||||||
"Given a Diretory, gets files, Filtered to those having scss or sass
|
"Given a Diretory, gets files, Filtered to those having scss or sass
|
||||||
extention. Ignores files matching any ignored regexps."
|
extention. Ignores files matching any ignored regexps."
|
||||||
|
@ -24,9 +34,11 @@
|
||||||
done by sh / launching the sass command."
|
done by sh / launching the sass command."
|
||||||
[sass-file
|
[sass-file
|
||||||
src-sass
|
src-sass
|
||||||
dest-sass]
|
dest-sass
|
||||||
|
compass?]
|
||||||
(sh "sass"
|
(sh "sass"
|
||||||
"--update"
|
"--update"
|
||||||
|
(when compass? "--compass")
|
||||||
(str src-sass "/" sass-file)
|
(str src-sass "/" sass-file)
|
||||||
(str dest-sass "/" )))
|
(str dest-sass "/" )))
|
||||||
|
|
||||||
|
@ -42,15 +54,16 @@ the command. Shows you any problems it comes across when compiling. "
|
||||||
;; I found sass files,
|
;; I found sass files,
|
||||||
;; If sass is installed
|
;; If sass is installed
|
||||||
(if (sass-installed?)
|
(if (sass-installed?)
|
||||||
;; I compile all files
|
(let [compass? (compass-installed?)]
|
||||||
(doseq [a-file sass-files]
|
;; I compile all files
|
||||||
(println "Compiling Sass File:" a-file)
|
(doseq [a-file sass-files]
|
||||||
(let [result (compile-sass-file! a-file src-sass dest-sass)]
|
(println "Compiling Sass File:" a-file src-sass dest-sass)
|
||||||
(if (zero? (:exit result))
|
(let [result (compile-sass-file! a-file src-sass dest-sass compass?)]
|
||||||
;; no problems in sass compilation
|
(if (zero? (:exit result))
|
||||||
(println "Successfully compiled:" a-file)
|
;; no problems in sass compilation
|
||||||
;; else I show the error
|
(println "Successfully compiled:" a-file)
|
||||||
(println (:err result)))))
|
;; else I show the error
|
||||||
|
(println (:err result))))))
|
||||||
;; Else I prompt to install Sass
|
;; Else I prompt to install Sass
|
||||||
(println "Sass seems not to be installed, but you have scss / sass files in "
|
(println "Sass seems not to be installed, but you have scss / sass files in "
|
||||||
src-sass
|
src-sass
|
||||||
|
|
Loading…
Reference in a new issue