mirror of
https://github.com/anoma/juvix.git
synced 2024-12-21 05:41:49 +03:00
21 lines
800 B
Haskell
21 lines
800 B
Haskell
|
module Commands.Dev.MigrateJuvixYaml where
|
||
|
|
||
|
import Commands.Base
|
||
|
import Commands.Dev.MigrateJuvixYaml.Options
|
||
|
import Commands.Extra.Package
|
||
|
import Juvix.Extra.Paths
|
||
|
|
||
|
runCommand :: forall r. (Members '[Embed IO, Files, App] r) => MigrateJuvixYamlOptions -> Sem r ()
|
||
|
runCommand MigrateJuvixYamlOptions {..} = do
|
||
|
pkgDir <- askPkgDir
|
||
|
isGlobalPackage <- askPackageGlobal
|
||
|
let pkgFilePath = pkgDir <//> packageFilePath
|
||
|
pkgFileExists <- fileExists' pkgFilePath
|
||
|
pkg <- askPackage
|
||
|
if
|
||
|
| isGlobalPackage -> exitMsg (ExitFailure 1) "No Package file found"
|
||
|
| not pkgFileExists || _migrateJuvixYamlOptionsForce -> do
|
||
|
writePackageFile pkgDir pkg
|
||
|
removeFile' (pkgDir <//> juvixYamlFile)
|
||
|
| otherwise -> exitMsg (ExitFailure 1) (show pkgFilePath <> " already exists.")
|