|
@@ -32,24 +32,26 @@
|
|
|
(let [repo (state/get-current-repo)
|
|
|
dir (config/get-repo-dir repo)
|
|
|
path (load-path location)]
|
|
|
- (-> (p/chain (fs/stat dir path)
|
|
|
- (fn [stat]
|
|
|
- (when stat
|
|
|
- (fs/read-file dir path)))
|
|
|
- (fn [content]
|
|
|
- (when (not-empty content)
|
|
|
- (try (cljs.reader/read-string content)
|
|
|
- (catch js/Error e
|
|
|
- (println (util/format "read persist-var failed: %s" (load-path location)))
|
|
|
- (js/console.dir e)))))
|
|
|
- (fn [value]
|
|
|
- (when (some? value)
|
|
|
- (swap! *value (fn [o]
|
|
|
- (-> o
|
|
|
- (assoc-in [repo :loaded?] true)
|
|
|
- (assoc-in [repo :value] value)))))))
|
|
|
- (p/catch (fn [e]
|
|
|
- (println (util/format "load persist-var failed: %s: %s" (load-path location) e))))))))
|
|
|
+ (p/let [file-exists? (fs/file-exists? dir path)]
|
|
|
+ (when file-exists?
|
|
|
+ (-> (p/chain (fs/stat dir path)
|
|
|
+ (fn [stat]
|
|
|
+ (when stat
|
|
|
+ (fs/read-file dir path)))
|
|
|
+ (fn [content]
|
|
|
+ (when (not-empty content)
|
|
|
+ (try (cljs.reader/read-string content)
|
|
|
+ (catch js/Error e
|
|
|
+ (println (util/format "read persist-var failed: %s" (load-path location)))
|
|
|
+ (js/console.dir e)))))
|
|
|
+ (fn [value]
|
|
|
+ (when (some? value)
|
|
|
+ (swap! *value (fn [o]
|
|
|
+ (-> o
|
|
|
+ (assoc-in [repo :loaded?] true)
|
|
|
+ (assoc-in [repo :value] value)))))))
|
|
|
+ (p/catch (fn [e]
|
|
|
+ (println (util/format "load persist-var failed: %s: %s" (load-path location) e))))))))))
|
|
|
(-loaded? [_]
|
|
|
(get-in @*value [(state/get-current-repo) :loaded?]))
|
|
|
|