├── CHANGELOG.md ├── LICENSE ├── README.md ├── boot.properties ├── build.boot └── src └── samestep └── boot_refresh.clj /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. This 4 | project adheres to [Semantic Versioning]. This change log follows the 5 | conventions of [Keep a CHANGELOG]. 6 | 7 | ## 0.1.0 - 2016-06-20 8 | ### Added 9 | - `refresh` task to reload changed namespaces and throw on failure 10 | 11 | [keep a changelog]: http://keepachangelog.com/ 12 | [semantic versioning]: http://semver.org/ 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2017 Samuel Estep 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # boot-refresh 2 | 3 | [![Clojars Project][clojars badge]][clojars] 4 | 5 | [Boot] task to reload code using [`clojure.tools.namespace`][tools.namespace]. 6 | 7 | ## Usage 8 | 9 | In `build.boot`, add `boot-refresh` to your dependencies and `require` the task: 10 | 11 | ```clojure 12 | (merge-env! :dependencies '[[samestep/boot-refresh "0.1.0" :scope "test"]]) 13 | 14 | (require '[samestep.boot-refresh :refer [refresh]]) 15 | ``` 16 | 17 | You can view the help info for the `refresh` task from the command line: 18 | 19 | ```sh 20 | boot refresh -h 21 | ``` 22 | 23 | The `refresh` task works best with [CIDER]: 24 | 25 | ```lisp 26 | (setq cider-boot-parameters "repl -s watch refresh") 27 | 28 | (cider-jack-in) 29 | ``` 30 | 31 | If you modify any of your source files and save your changes, you should be able 32 | to immediately use the new code from your REPL. 33 | 34 | ## Development 35 | 36 | To work on `boot-refresh` itself, you can use the provided `dev` task: 37 | 38 | ```sh 39 | boot dev 40 | ``` 41 | 42 | This will start a watch loop that will reinstall the jar whenever one of 43 | `boot-refresh`'s files changes. 44 | 45 | [boot]: https://boot-clj.github.io/ 46 | [cider]: https://github.com/clojure-emacs/cider 47 | [clojars]: https://clojars.org/samestep/boot-refresh 48 | [clojars badge]: https://clojars.org/samestep/boot-refresh/latest-version.svg 49 | [tools.namespace]: https://github.com/clojure/tools.namespace 50 | -------------------------------------------------------------------------------- /boot.properties: -------------------------------------------------------------------------------- 1 | BOOT_CLOJURE_VERSION=1.8.0 2 | BOOT_VERSION=2.7.1 3 | -------------------------------------------------------------------------------- /build.boot: -------------------------------------------------------------------------------- 1 | (set-env! 2 | :resource-paths #{"src"} 3 | :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"] 4 | [boot/core "2.6.0" :scope "provided"] 5 | [org.clojure/tools.namespace "0.2.11"] 6 | [adzerk/bootlaces "0.1.13" :scope "test"]]) 7 | 8 | (require '[adzerk.bootlaces :refer :all]) 9 | 10 | (def +version+ "0.1.0") 11 | 12 | (bootlaces! +version+ :dont-modify-paths? true) 13 | 14 | (task-options! 15 | pom {:project 'samestep/boot-refresh 16 | :version +version+ 17 | :description "Boot task to reload code using clojure.tools.namespace." 18 | :url "https://github.com/samestep/boot-refresh" 19 | :scm {:url "https://github.com/samestep/boot-refresh"} 20 | :license {"MIT License" "https://opensource.org/licenses/MIT"}}) 21 | 22 | (deftask dev 23 | "Dev process" 24 | [] 25 | (comp 26 | (watch) 27 | (repl :server true) 28 | (pom) 29 | (jar) 30 | (install))) 31 | -------------------------------------------------------------------------------- /src/samestep/boot_refresh.clj: -------------------------------------------------------------------------------- 1 | (ns samestep.boot-refresh 2 | {:boot/export-tasks true} 3 | (:require [boot.core :as boot] 4 | [clojure.tools.namespace.repl :as tns])) 5 | 6 | (boot/deftask refresh 7 | "Reload all changed namespaces on the classpath. 8 | 9 | Throws an exception in the case of failure." 10 | [] 11 | (boot/with-pass-thru _ 12 | (apply tns/set-refresh-dirs (boot/get-env :directories)) 13 | (with-bindings {#'*ns* *ns*} 14 | (let [result (tns/refresh)] 15 | (when (instance? Throwable result) 16 | (throw result)))))) 17 | --------------------------------------------------------------------------------