Module

Node.Process

Package
purescript-node-process
Repository
purescript-node/purescript-node-process

Bindings to the global process object in Node.js. See also the Node API documentation

#onBeforeExit Source

onBeforeExit :: Effect Unit -> Effect Unit

Register a callback to be performed when the event loop empties, and Node.js is about to exit. Asynchronous calls can be made in the callback, and if any are made, it will cause the process to continue a little longer.

#onExit Source

onExit :: (Int -> Effect Unit) -> Effect Unit

Register a callback to be performed when the process is about to exit. Any work scheduled via asynchronous calls made here will not be performed in time.

The argument to the callback is the exit code which the process is about to exit with.

#onSignal Source

onSignal :: Signal -> Effect Unit -> Effect Unit

Install a handler for a particular signal.

#onUncaughtException Source

onUncaughtException :: (Error -> Effect Unit) -> Effect Unit

Install a handler for uncaught exceptions. The callback will be called when the process emits the uncaughtException event. The handler currently does not expose the second origin argument from the Node 12 version of this event to maintain compatibility with older Node versions.

#onUnhandledRejection Source

onUnhandledRejection :: forall a b. (a -> b -> Effect Unit) -> Effect Unit

Install a handler for unhandled promise rejections. The callback will be called when the process emits the unhandledRejection event.

The first argument to the handler can be whatever type the unhandled Promise yielded on rejection (typically, but not necessarily, an Error).

The handler currently does not expose the type of the second argument, which is a Promise, in order to allow users of this library to choose their own PureScript Promise bindings.

#nextTick Source

nextTick :: Effect Unit -> Effect Unit

Register a callback to run as soon as the current event loop runs to completion.

#argv Source

argv :: Effect (Array String)

Get an array containing the command line arguments.

#execArgv Source

execArgv :: Effect (Array String)

Node-specific options passed to the node executable.

#execPath Source

execPath :: Effect String

The absolute pathname of the node executable that started the process.

#chdir Source

chdir :: String -> Effect Unit

Change the current working directory of the process. If the current directory could not be changed, an exception will be thrown.

#cwd Source

cwd :: Effect String

Get the current working directory of the process.

#getEnv Source

getEnv :: Effect (Object String)

Get a copy of the current environment.

#lookupEnv Source

lookupEnv :: String -> Effect (Maybe String)

Lookup a particular environment variable.

#setEnv Source

setEnv :: String -> String -> Effect Unit

Set an environment variable.

#unsetEnv Source

unsetEnv :: String -> Effect Unit

Delete an environment variable. Use case: to hide secret environment variable from child processes.

#exit Source

exit :: forall a. Int -> Effect a

Cause the process to exit with the supplied integer code. An exit code of 0 is normally considered successful, and anything else is considered a failure.

#stdin Source

stdin :: Readable ()

The standard input stream. Note that this stream will never emit an end event, so any handlers attached via onEnd will never be called.

#stdout Source

stdout :: Writable ()

The standard output stream. Note that this stream cannot be closed; calling end will result in an exception being thrown.

#stderr Source

stderr :: Writable ()

The standard error stream. Note that this stream cannot be closed; calling end will result in an exception being thrown.

#stdinIsTTY Source

stdinIsTTY :: Boolean

Check whether the standard input stream appears to be attached to a TTY. It is a good idea to check this before processing the input data from stdin.

#stdoutIsTTY Source

stdoutIsTTY :: Boolean

Check whether the standard output stream appears to be attached to a TTY. It is a good idea to check this before printing ANSI codes to stdout (e.g. for coloured text in the terminal).

#stderrIsTTY Source

stderrIsTTY :: Boolean

Check whether the standard error stream appears to be attached to a TTY. It is a good idea to check this before printing ANSI codes to stderr (e.g. for coloured text in the terminal).

#version Source

version :: String

Get the Node.js version.