Merge pull request #35 from raboof/no-separate-main

Remove separate main.cljs, install to PATH
This commit is contained in:
Dmitri Sotnikov 2020-03-19 10:40:20 -04:00 committed by GitHub
commit d72b755485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 11 deletions

6
mastodon_bot/core.cljs Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/env lumo
(ns mastodon-bot.core (ns mastodon-bot.core
(:require (:require
[cljs.core :refer [*command-line-args*]] [cljs.core :refer [*command-line-args*]]
@ -206,7 +208,7 @@
(exit-with-error (exit-with-error
(str "failed to connect to Tumblr account " account ": " (.-message e)))))) (str "failed to connect to Tumblr account " account ": " (.-message e))))))
(defn main [] (defn -main []
(get-mastodon-timeline (get-mastodon-timeline
(fn [timeline] (fn [timeline]
(let [last-post-time (-> timeline first :created_at (js/Date.))] (let [last-post-time (-> timeline first :created_at (js/Date.))]
@ -232,3 +234,5 @@
(let [parser (rss.)] (let [parser (rss.)]
(doseq [feed feeds] (doseq [feed feeds]
(parse-feed last-post-time parser feed)))))))) (parse-feed last-post-time parser feed))))))))
(set! *main-cli-fn* -main)

View file

@ -27,3 +27,6 @@
))) )))
(cljs.test/run-tests) (cljs.test/run-tests)
; Don't run core's -main when testing
(set! *main-cli-fn* ())

View file

@ -1,9 +0,0 @@
#!/usr/bin/env lumo
(ns mastodon-bot.main
(:require
[mastodon-bot.core :as core]))
(core/main)

View file

@ -16,7 +16,10 @@
"shadow-cljs": "^2.8.37" "shadow-cljs": "^2.8.37"
}, },
"scripts": { "scripts": {
"start": "./mastodon_bot/main.cljs", "start": "./mastodon_bot/core.cljs",
"test": "MASTODON_BOT_CONFIG=test.edn ./mastodon_bot/core_test.cljs" "test": "MASTODON_BOT_CONFIG=test.edn ./mastodon_bot/core_test.cljs"
},
"bin": {
"mastodon-bot": "mastodon_bot/core.cljs"
} }
} }