Fork me on GitHub
#leiningen
<
2020-04-06
>
chadhs11:04:00

is it possible to in include a filepath wildcard in a lein alias?

chadhs11:04:42

goals is to have this in my aliases map "format" ["zprint" "src/**/*.clj"]

chadhs11:04:08

i end up getting this error however

Unable to process file: src/**/*.clj because: .FileNotFoundException: src/**/*.clj (No such file or directory) Leaving it unchanged!

teodorlu11:04:19

@chadhs is src/**/*.clj shell syntax? I see that ls src/**/*.clj lists Clojure files, with a bit different behavior on Bash and Zsh.

chadhs12:04:59

@teodorlu yes it is

chadhs12:04:27

interesting… sh and bash do behave differently than zsh with that

teodorlu12:04:08

I'd consider either looking into if zprint supports file search itself, or try to make some pipeline. If you want to go for the pipeline approach, something like

find src -iname '*.clj' | xargs echo
could work. When run from Lein, I suspect you'll have to bash -c or similar to get the pipe to work.
bash -c 'find src -iname "*.clj" | xargs echo'

teodorlu12:04:20

Not sure if it's a good idea to put that thing into a lein alias. You'll be the judge 🙂

chadhs10:04:35

@teodorlu it’s not pretty but i have a format.sh with this

#!/usr/bin/env zsh

unset CLASSPATH

lein zprint src/**/*.clj*

chadhs11:04:08

and an alias using lein-shell like this

"format" ["shell" "./format.sh"]

teodorlu11:04:02

Nice! -- Well, depends on our definition of nice. Glad you got it working 🙂

teodorlu11:04:22

Seems like a good case for ZSH, actually. As long as ZSH is installed.

chadhs11:04:29

that’s the rub. not sure if i want to rely on that. it’s on macs by default; so i’ll have to think on that more.

chadhs11:04:04

goal is pre-commit hook that will format with zprint and then lint with clj-kondo all using dev deps and aliases in project.clj so there’s no reliance on having the os binaries of those tools installed.

teodorlu12:04:05

Is find preinstalled on macs? I don't think I've found a Linux system missing it.

lein zprint `find src -iname '*.clj'
`

chadhs10:04:34

yes, since it’s a BSD under the hood. of the utils are a bit different than their GNU counterparts, but yes find is there ^_^

arohner21:04:50

I’m trying to use :pedantic :abort? to make sure I have no ambiguous dependencies, but it doesn’t appear to behave the way I’d like. For example, I currently have

[s3-wagon-private "1.3.3"] -> [com.fasterxml.jackson.core/jackson-core "2.9.9"]
 overrides
[s3-wagon-private "1.3.3"] -> [com.fasterxml.jackson.core/jackson-databind "2.9.10.1"] -> [com.fasterxml.jackson.core/jackson-core "2.9.10"]
but jackson-core is in :managed-dependencies, so I’d expect that there aren’t problems with that dep

arohner21:04:24

Is there a different way to achieve this?

danielcompton23:04:27

Not sure if :plugins works with :managed-dependencies?