Skip to content

Instantly share code, notes, and snippets.

@ampersanda
Last active December 5, 2023 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ampersanda/cd44591d4d214053e6e971493f4d234c to your computer and use it in GitHub Desktop.
Save ampersanda/cd44591d4d214053e6e971493f4d234c to your computer and use it in GitHub Desktop.
Babashka Script to setup fvm version from pubspec.yaml's environment key
;; 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