Last active
December 5, 2023 14:48
-
-
Save ampersanda/cd44591d4d214053e6e971493f4d234c to your computer and use it in GitHub Desktop.
Babashka Script to setup fvm version from pubspec.yaml's environment key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; environment: | |
;; sdk: '>=3.1.5 <4.0.0' | |
;; flutter: '3.16.2' <- from this one | |
#!/usr/bin/env bb | |
(require | |
'[babashka.process :refer [shell process exec]] | |
'[clojure.java.io :as io]) | |
(def pubspec-content (slurp "pubspec.yaml")) | |
(def version | |
(let [match (re-find #"flutter: '([.\d]+)'" pubspec-content)] | |
(second match))) | |
(shell "fvm use" version) | |
(spit ".envrc" "PATH_add .fvm/flutter_sdk/bin/" :append true) | |
(if-let [need-install? (= 1 (some-> (shell/sh "command" "-v" "direnv") | |
:exit))] | |
(shell "brew install direnv")) | |
;; zsh needs to run `eval "$(direnv hook zsh)"` | |
(shell "direnv allow") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment