Fork me on GitHub
#boot
<
2016-12-01
>
pesterhazy10:12:31

I'm thinking of writing a boot task to auto-format clj(s) code, similar to golang's gofmt tool, based on https://github.com/kkinnear/zprint. I'd like to change files in the repository. To determine the file list, would it make sense to look at the source paths to get a list of all the clj(s) files to reformat? Or should it do git ls-files and go from there?

martinklepsch11:12:48

@pesterhazy that's cool (zprint and a boot task for it)!

martinklepsch11:12:43

I think file-seq on the directories that are listed in :source-paths (and maybe :resource-paths) would be fine, can't think of a good reason to use the fileset stuff in this case

pesterhazy11:12:12

yeah that's what I thought

pesterhazy11:12:05

ultimately the tool should replace files in your repo (so you can use git diff to check differences), and boot only writes to a designated target dir

pesterhazy11:12:08

(quite sensibly)

juhoteperi11:12:37

Hmh, this tools sounds like it doesn't benefit much from Boot features

juhoteperi11:12:57

I'd probably just write a function that takes path or paths that should be checked and updates files in place

juhoteperi11:12:27

Additionally there could be Boot task wrapper which calls this function with boot source/resource-paths

pesterhazy11:12:22

additionally, getting the list of files from git seems like a useful (optional) addition too

juhoteperi11:12:50

Perhaps, but contents of source-paths should be nearly the same anyways

mitchelkuijpers12:12:33

@pesterhazy I was looking at cljfmt for this But this also might be interesting

mitchelkuijpers12:12:06

Just out of curiosity why not use cljfmt? Especially when we implement: https://github.com/weavejester/cljfmt/issues/49

martinklepsch12:12:17

@mitchelkuijpers FWIW there's a very nice cljfmt thing on npm (I think) that you can just run as a script

mitchelkuijpers12:12:19

Ah that is also cool, but I am leaning towards cljfmt with the nice indentation metadata

mitchelkuijpers12:12:05

I would like a sort of standardized solution (if possible at all) And it helps that this has cider integration (sort of)

pesterhazy13:12:26

@mitchelkuijpers zprint seems a lot more powerful and configurable

pesterhazy13:12:10

might even be possible to pick between two "backend" pprinters

pesterhazy13:12:15

in either case a boot task would be useful to simplify integration

mitchelkuijpers13:12:23

@pesterhazy yes it seems very powerfull

mitchelkuijpers13:12:32

@pesterhazy I am not sure what you are looking for but our team is looking for elm-format like functionality where you just stop thinking about formatting

mitchelkuijpers13:12:44

Makes life so much easier

pesterhazy13:12:54

that's what I'm looking for as well

pesterhazy13:12:16

potentially with ci integration (complain if not compliant)

mitchelkuijpers13:12:43

If I can help in any way let me know @pesterhazy

pesterhazy13:12:23

thanks, I'll let you know!

flyboarder16:12:17

@micha I'm working on my boot-nodejs task, how can I make the server restart when using the watch task? I modeled it after boot-jetty.

micha16:12:40

when do you want it to restart exactly?

flyboarder16:12:48

Whenever cljs files change

micha16:12:33

that task uses a delay to make starting the server idempotent

micha16:12:50

like calling @start many times only starts the server once

micha16:12:12

you can just make that a function that (re)starts the server instead of a delay

micha16:12:18

then it will restart it every time

micha16:12:42

you can also do a fileset diff and filter to only restart when a .cljs file changes

flyboarder16:12:52

@micha would that spawn multiple processes until boot shuts down?

micha16:12:31

presumably the restart process would handle that, no?

flyboarder16:12:07

I'd have to manually do that I guess, maybe check for an atom instead of using def

flyboarder16:12:26

That way I know when to try and kill the process

micha16:12:34

or record the pid

micha16:12:53

in an atom or something

micha16:12:17

maybe there is a socket repl for nodejs you can use

micha16:12:30

i dunno, just brainstorming here

flyboarder16:12:47

Yeah I would eventually like to do live reload