Remove separate main.cljs, install to PATH

https://docs.npmjs.com/files/package.json#bin
This commit is contained in:
Arnout Engelen 2020-03-19 09:55:26 +01:00
parent 180f2a6eb5
commit 043f1e0fd3
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
(:require
[cljs.core :refer [*command-line-args*]]
@ -206,7 +208,7 @@
(exit-with-error
(str "failed to connect to Tumblr account " account ": " (.-message e))))))
(defn main []
(defn -main []
(get-mastodon-timeline
(fn [timeline]
(let [last-post-time (-> timeline first :created_at (js/Date.))]
@ -232,3 +234,5 @@
(let [parser (rss.)]
(doseq [feed feeds]
(parse-feed last-post-time parser feed))))))))
(set! *main-cli-fn* -main)

View file

@ -27,3 +27,6 @@
)))
(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"
},
"scripts": {
"start": "./mastodon_bot/main.cljs",
"start": "./mastodon_bot/core.cljs",
"test": "MASTODON_BOT_CONFIG=test.edn ./mastodon_bot/core_test.cljs"
},
"bin": {
"mastodon-bot": "mastodon_bot/core.cljs"
}
}