App
Module | ejs.sys |
Definition | class App |
Inheritance | App ![]() |
Specified | ejscript-1.1 |
Stability | Evolving. |
Application configuration state.
The App class is a singleton class object. The App class is accessed via the App global type object. It provides methods to interrogate and control the applications environment including the current working directory, application command line arguments, path to the application's executable and input and output streams.
Properties
Qualifiers | Property | Type | Description |
---|---|---|---|
public static get | args | Array | Application command line arguments. Set to an array containing each of the arguments. If the ejs command is invoked as "ejs script arg1 arg2", then args[0] will be "script", args[1] will be "arg1" etc. |
public static get | dir | Path | The application's current directory. |
public static get | errorStream | Stream | The application's standard error file stream. |
public static get | exeDir | Path | The directory containing the application executable. |
public static get | exePath | Path | The application executable path. |
public static get | inputStream | Stream | The application's standard input file stream. |
public static get | name | String | Application name. Set to a single word, lower case name for the application. |
public static get | outputStream | Stream | The application's standard output file stream. |
public static get set | searchPath | String | The current module search path. Set to a delimited searchPath string. Warning: This will be changed to an array of paths in a future release. |
public static get | title | String | Application title name. Multi-word, Camel Case name for the application suitable for display. |
public static get | version | String | Application version string. Set to a version string of the format Major.Minor.Patch-Build. For example: 1.1.2-3. |
App Methods
Qualifiers | Method |
---|---|
public static | chdir(value: Object): Void |
Change the application's Working directory. | |
public static | exit(status: Number = 0): Void |
Stop the program and exit. | |
public static | getenv(name: String): String |
Get an environment variable. | |
public static | noexit(exit: Boolean = true): Void |
Control whether an application will exit when global scripts have completed. | |
public static | putenv(name: String, value: String): Void |
Update an environment variable. | |
public static | serviceEvents(count: Number = -1 , timeout: Number = -1): Void |
Service events. | |
public static | sleep(delay: Number = -1): Void |
Sleep the application for the given number of milliseconds. |
Method Detail
Change the application's Working directory.
- Parameters
value: Object The path to the new working directory.
Stop the program and exit.
- Parameters
status: Number The optional exit code to provide the environment. If running inside the ejs command program, the status is used as process exit status. [default: 0]
Get an environment variable.
- Parameters
name: String The name of the environment variable to retrieve.
- Returns
- The value of the environment variable or null if not found.
Control whether an application will exit when global scripts have completed.
- Description
- Setting this to true will cause the application to continue servicing events until the exit method is explicitly called. The default application setting of noexit is false.
- Parameters
exit: Boolean If true, the application will exit when the last script completes. [default: true]
Sleep the application for the given number of milliseconds.
- Parameters
delay: Number Time in milliseconds to sleep. Set to -1 to sleep forever. [default: -1]