This script cleans up destination directory and copies file into it with new name. Can this intent be expressed more cleanly with shelly
?
main = shellyFailDir $ verbosely $ do
escaping False $ rm_rf $ webapps </> "*"
cp (m2repo
</> groupPath
</> artifact
</> version
</> (intercalate "-" [artifact, version] `append` ".war")
) $ webapps </> (finalName `append` ".war")
echo "done"
Alternate take:
main = shellyFailDir $ verbosely $ do
ls webapps >>= mapM_ rm_rf
cp (m2repo <> groupPath <> (mconcat . map fromText $ [artifact, version, artifactFileName]))
$ webapps <> fromText (finalName <> extension)
echo "done"
artifactFileName = intercalate "-" [artifact, version] <> extension
Having (types match only second version because they help pick correct Monoid
):
m2repo = ".m2/repository" :: FilePath
version = "1.0-SNAPSHOT" :: Text
webapps = "tomcat/webapps" :: FilePath
groupPath = "com/example" :: FilePath
artifact = "app" :: Text
finalName = artifact
extension = ".war" :: Text