From 043f1e0fd39425f13e67c301d98a0061db9de269 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Thu, 19 Mar 2020 09:55:26 +0100 Subject: [PATCH] Remove separate main.cljs, install to PATH https://docs.npmjs.com/files/package.json#bin --- mastodon_bot/core.cljs | 6 +++++- mastodon_bot/core_test.cljs | 3 +++ mastodon_bot/main.cljs | 9 --------- package.json | 5 ++++- 4 files changed, 12 insertions(+), 11 deletions(-) mode change 100644 => 100755 mastodon_bot/core.cljs delete mode 100755 mastodon_bot/main.cljs diff --git a/mastodon_bot/core.cljs b/mastodon_bot/core.cljs old mode 100644 new mode 100755 index 3cd7bee..bb47c75 --- a/mastodon_bot/core.cljs +++ b/mastodon_bot/core.cljs @@ -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) diff --git a/mastodon_bot/core_test.cljs b/mastodon_bot/core_test.cljs index fdae4d4..fdc5e91 100755 --- a/mastodon_bot/core_test.cljs +++ b/mastodon_bot/core_test.cljs @@ -27,3 +27,6 @@ ))) (cljs.test/run-tests) + +; Don't run core's -main when testing +(set! *main-cli-fn* ()) diff --git a/mastodon_bot/main.cljs b/mastodon_bot/main.cljs deleted file mode 100755 index 976c8e2..0000000 --- a/mastodon_bot/main.cljs +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env lumo - -(ns mastodon-bot.main - (:require - [mastodon-bot.core :as core])) - -(core/main) - - diff --git a/package.json b/package.json index 4969228..06703ae 100644 --- a/package.json +++ b/package.json @@ -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" } }