Module

Node.Library.EnvPaths

Package
purescript-node-env-paths
Repository
jordanmartinez/purescript-node-env-paths

Constructs the platform-independent file paths for commonly used storage places. These paths may not exist on the computer, so calls to mkdir -p may be necessary.

#EnvPaths Source

type EnvPaths = { cache :: FilePath, config :: FilePath, data :: FilePath, log :: FilePath, temp :: FilePath }

Platform-generic file paths.

#EnvPathsContext Source

newtype EnvPathsContext

Context needed to accurately produce an EnvPaths value.

#envPaths Source

envPaths :: { ctx :: EnvPathsContext, name :: String, suffix :: Maybe String } -> EnvPaths

Gets the paths based on information obtained previously sometime in the past. Since these values rarely change, the below example should be safe for most usages.

foo = do
  ctx <- envPathsContext
  -- if user changes an environment value after this call
  -- then `paths` below will provide out-of-date information.
  let paths = envPaths' ctx { name: "foo", suffix: Nothing }

The suffix arg defaults to -nodejs to prevent name conflicts with native apps.

#envPathsNow Source

envPathsNow :: { name :: String, suffix :: Maybe String } -> Effect EnvPaths

Variant of envPaths that immediately gets path information at the cost of running in Effect.