|
definition: |
getPackageVersionOfDirectory :: FilePath -> IO (Maybe (String,String))
getPackageVersionOfDirectory path =
if sysLibPath == [path]
then return (Just ("base",baseVersion))
else getPackageSpecPath path >>=
return . maybe Nothing
(\pdir -> splitPkgId "" (last (splitDirectories pdir)))
where
splitPkgId oldpn s =
let (pname,hvers) = break (=='-') s
newpn = if null oldpn then pname else oldpn ++ "-" ++ pname
in if null hvers
then Nothing
else let vers = tail hvers
in if isVersionId vers then Just (newpn,vers)
else splitPkgId newpn vers
isVersionId vs = case split (=='.') vs of
(maj:min:patch:_) -> all (all isDigit) [maj, min, take 1 patch]
_ -> False
|
|
demand: |
no demanded arguments |
|
deterministic: |
deterministic operation |
|
documentation: |
Checks whether a directory path is part of a package and returns
the package name and package version. For instance,
getPackageVersionOfDirectory "/home/joe/mytool/.cpm/packages/process-3.0.0/src"
returns
Just "process" "3.0.0"
For this purpose, it is checked whether there is a `package.json` file
under the directory and the directory name is a valid package id.
|
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_) |-> _}
|
|
name: |
getPackageVersionOfDirectory |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
String -> Prelude.IO (Prelude.Maybe (String, String)) |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |