Closed binarykitchen closed 2 years ago
I think the easiest is to just name the run alias something else :)
But considering you're doing a lot of repeated work for each task, maybe you should have a look at :prep-tasks
and profile merging (with-profile
). The profiles documentation has some notes on how you could potentially do it.
Naming the run alias to something else won't solve it because I want to run Gulp tasks before the infamous lein run
. But when running in development mode, i.E. with lein dev
I want to run different Gulp tasks before lein run
. That's the problem.
I cannot use :prep-tasks
to solve this because they are always executed, no matter what lein command you are picking. Would be nice to have prep-tasks selective per command.
(profiles, nice but that would add more complexity we want to avoid)
I'll see if there's any way to do this with pure lein, but it's not on my top priority right now. I'll keep it open though, as it's probably enough interest to find a general solution to something like this.
@binarykitchen You probably figured this out already, but to anyone else who comes across this the answer is in the do
syntax. You must separate the tasks to want to run in an alias with a comma. Like so from command line:
$ lein do shell gulp, jar
But of course, Clojure arrays don't care about commas, so the comma must be added inside the quotes. In an example where you want to run lein shell gulp
then lein jar
you'd write:
:aliases {
jar ["do" "shell" "gulp," "jar"]
}
The do
task documentation is very sparse, but here's what I could find: https://github.com/technomancy/leiningen#basic-usage
thx, this is good, works for me (yes, have figured that out)
Today I wanted to do a similar thing. My problem is the checkouts feature. I have to run lein jar
, lein install
, lein uberjar
(and similar) without checkouts directory if present (checkout projects are causing troubles in my own project.clj because their lein plugins get automatically included in my project). I wish I could disable it on per-profile basis, but unfortunately Iein does not have such an option. So I wanted to define aliases which would wrap lein invocation with a simple bash script, which would move checkout out and then move it back. But I hit this same issue of 'How to invoke original task without aliases being applied?'
Fortunately turns out there exists a solution using :profiles
and lein-shell
plugin for the price of nested lein invocation (which I'm willing to pay):
:profiles {:nuke-aliases {:aliases ^:replace {}}}
:plugins [[lein-shell "0.4.2"]]
:aliases { jar ["shell" "scripts/lein-without-checkouts.sh" "jar"] }
where scripts/lein-without-checkouts.sh
does something like this:
lein with-profile "+nuke-aliases" "$@"
The actual script is here: https://github.com/binaryage/dirac/blob/master/scripts/lein-without-checkouts.sh
It sounds like we have a solution for this.
Hello again
I have this configuration here:
You see that I am running gulp first for some commands. But the problem is within the
dev
alias, where I callrun
together withgulp-dev
whereas therun
will trigger therun
alias which will run gulp.How can I call
run
inside thedev
alias without the associated alias?