Closed teodorlu closed 5 months ago
I get correct indents when I have zero aliases other than :kaocha
, but wrong indents when I have other aliases.
Good behavior:
$ cat deps.edn
{:deps {}}
$ neil-dev add kaocha
"adding kaocha"
If you wish to create a `bin/kaocha` file, copy and run the following:
mkdir -p bin && \
echo '#!/usr/bin/env bash
clojure -M:kaocha "$@"' > bin/kaocha && \
chmod +x bin/kaocha
$ cat deps.edn
{:deps {}
:aliases
{:kaocha ;; added by neil
{:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:main-opts ["-m" "kaocha.runner"]}}}
Bad behavior:
$ cat deps.edn
{:deps {}
:aliases
{:dev {}}}
$ neil-dev add kaocha
"adding kaocha"
If you wish to create a `bin/kaocha` file, copy and run the following:
mkdir -p bin && \
echo '#!/usr/bin/env bash
clojure -M:kaocha "$@"' > bin/kaocha && \
chmod +x bin/kaocha
$ cat deps.edn
{:deps {}
:aliases
{:dev {}
:kaocha ;; added by neil
{:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:main-opts ["-m" "kaocha.runner"]}}}
babashka.neil/add-alias
appears to be the function to understand: https://github.com/babashka/neil/blob/9a795828e4c201a47c5851157868c06f2ca37448/src/babashka/neil.clj#L131-L166
@borkdude I feel tempted to drop the previous logic that tried to compute the correct in favor of a dumb approach: repeatedly using rewrite-edn/assoc-in
, and accepting the result. If we go this way, newline behavior will change.
Previous add-alias
impl relies on a hard-coded 1
value for indention, which I think is causing problems:
Proposal: instead, assume the user already has a deps.edn
file they are okay with, and that we can add content from the new map by adding one key + value per line:
No existing deps.edn
file.
Existing behavior:
$ neil add kaocha
If you wish to create a `bin/kaocha` file, copy and run the following:
mkdir -p bin && \
echo '#!/usr/bin/env bash
clojure -M:kaocha "$@"' > bin/kaocha && \
chmod +x bin/kaocha
$ cat deps.edn
{:deps {}
:aliases
{:kaocha ;; added by neil
{:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:main-opts ["-m" "kaocha.runner"]}}}
Proposed behavior:
$ rm deps.edn
$ neil-dev add kaocha
If you wish to create a `bin/kaocha` file, copy and run the following:
mkdir -p bin && \
echo '#!/usr/bin/env bash
clojure -M:kaocha "$@"' > bin/kaocha && \
chmod +x bin/kaocha
$ cat deps.edn
{:deps {}
:aliases {:kaocha {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:main-opts ["-m" "kaocha.runner"]}}}
Would you like to keep the current newline behavior?
Sounds good. Can you also test this with an already existing deps.edn file?
Sounds good.
👍
Can you also test this with an already existing deps.edn file?
I will 👍
What
When using Neil to add Kaocha (
neil add kaocha
), I get one fewer indent in front of the:kaocha
alias than I'd expect.Reproduction