Last active
January 26, 2022 15:03
-
-
Save ajchemist/c6a170afee5305c9211d4b3f9ce7282f to your computer and use it in GitHub Desktop.
Revisions
-
ajchemist revised this gist
Jan 26, 2022 . 1 changed file with 38 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,38 @@ (ns build (:require [clojure.java.io :as jio] [clojure.string :as str] [buddy.core.codecs :as codecs] [buddy.core.hash :as hash] )) (set! *warn-on-reflection* true) (defn module-hash-name [module] (subs (str/upper-case (codecs/bytes->hex (hash/md5 (jio/input-stream module)))) 0 8)) (defn rename-file [a b] (.renameTo (jio/file a) (jio/file b))) (defn rename-module-filename [f] {:pre [(.isFile (jio/file f))] :post [(.isFile (jio/file %))]} (let [file (jio/file f) parent (.getParent file) name (.getName file) idx (str/last-index-of name ".") target (jio/file parent (str (subs name 0 idx) "." (module-hash-name file) (subs name idx)))] (rename-file file target) target)) (comment (rename-module-filename "/tmp/out.css") ) -
ajchemist created this gist
Jan 26, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@