Node

This module allows you to start your application with access to application arguments, environment variables and the standard input and output streams.

To learn how to use this module's initialize function, take a closer look at the Node.Program module.

Initialization

type alias Configuration =
{ platform : Platform
, cpuArchitecture : CpuArchitecture
, args : Array String
, stdout : Stream
, stderr : Stream
, stdin : Stream
}

Contains information about the context your application was initiated.

  • platform and cpuArchitecture tells you something about the operating system and machine your application is running on.
  • args is an Array of the arguments passed to your application.
  • stdout, stderr and stdin are streams you can use to communicate with the outside world. Take a closer look at the Stream module for more information.
initialize : AppInitTask Configuration

Initialize a NodeJS application. In return you're granted the Configuration record, which contains useful context.

Info

type Platform
= Win32
| Darwin
| Linux
| FreeBSD
| OpenBSD
| SunOS
| Aix
| UnknownPlatform

The platform, or operating system, that your application is running on.

type CpuArchitecture
= Arm
| Arm64
| IA32
| Mips
| Mipsel
| PPC
| PPC64
| S390
| S390x
| X64
| UnknownArchitecture

The CPU architecture your application is running on.

getEnvironmentVariables : Task Never (Dict String String)

Get a Dict of environment variables.

Exit

exit : Cmd msg

Terminate the program immediatly. It will not wait for tasks like http calls or file system writes, so only use this if you've reached a state where it makes no sense to continue.

exitWithCode : Int -> Cmd msg

Terminate the program immediatly. It will not wait for tasks like http calls or file system writes, so only use this if you've reached a state where it makes no sense to continue.

The exit code can be read by other processes on your system. Any value other than 0 is considered an error.

setExitCode : Int -> Cmd msg

Set the error code that the program will return once it finishes.

Note: This will not terminate your program, so things like http calls or writes to the filesystem will be allowed to complete. However, the program will only exit once there are no ongoing tasks.