Module

Node.Library.Execa.NpmRunPath

Package
purescript-node-execa
Repository
jordanmartinez/purescript-node-execa

#NpmRunPathOptions Source

type NpmRunPathOptions = { cwd :: Maybe String, execPath :: Maybe String, path :: Maybe String }

cwd: the working directory. path: the PATH to be appended. Set it to an empty string to exclude the default PATH execPath: the pathe to the current Node.js executable. Its directory is pushed to the front of PATH. It can be either an absolute path or a path relative to the cwd option.

#npmRunPathEnv Source

npmRunPathEnv :: Object String -> NpmRunPathOptions -> Effect (Object String)

Modifies the given environment's PATH key so that any locally installed NPM binaries are executed. Works by recursively walking up the file system and prepending node_modules/.bin to the PATH.

In other words, given a cwd of parent1/parent2/root/, updates the PATH key to:

Array.intercalate Path.delimiter $
  [ "parent1/parent2/root/node_modules/.bin"
  , "parent1/parent2/node_modules/.bin"
  , "parent1/node_modules/.bin"
  ]
  <> (foldMap (\a -> [a]) $ Object.lookup "PATH" $ process.env)