README
node-get-app-root-path
Gets a node application or workspace root path. Provides environment and modules information and utilities.
API
Table of Contents
Table of contents
- getAppRootPath
- Interfaces
getAppRootPath
Interfaces
AppRootPath
getAppRootPath function
interface AppRootPath {
(): string
readonly isLambda: boolean
isLocal: boolean
isTesting: boolean
readonly isGitRepo: boolean
readonly manifest: IPackageManifest
readonly env: ProcessEnv
readonly initialCwd: string
path: string
name: string
getIsLocal(): boolean
setIsLocal(value: string | boolean): void
getIsTesting(): boolean
setIsTesting(value: string | boolean): void
getPath(): string
setPath(value: string): void
shortenPath(p: string, rootDir?: string | undefined): string
coreModule<Module extends NodeModule>(module: Module): Module
executableModule<Module extends NodeModule>(module: Module, functor: () => never | void | Promise<any>): Module
}
Call
(): string;
Return type
string
Method
getIsLocal(): boolean;
Return type
boolean
setIsLocal(value: string | boolean): void;
Parameters
Name | Type | Description |
---|---|---|
value | string | boolean | The boolean value. |
Return type
void
getIsTesting(): boolean;
Return type
boolean
setIsTesting(value: string | boolean): void;
Parameters
Name | Type | Description |
---|---|---|
value | string | boolean | The boolean value. |
Return type
void
getPath(): string;
Return type
string
setPath(value: string): void;
Parameters
Name | Type | Description |
---|---|---|
value | string | The new root folder path. |
Return type
void
shortenPath(p: string, rootDir?: string | undefined): string;
Parameters
Name | Type | Description |
---|---|---|
p | string | The path to shorten. |
rootDir | string | undefined | The root dir, by default is getAppRootPath() |
Return type
string
coreModule<Module extends NodeModule>(module: Module): Module;
Type parameters
Name | Constraint |
---|---|
Module | NodeModule |
Parameters
Name | Type | Description |
---|---|---|
module | Module | NodeJS module |
Return type
Module
executableModule<Module extends NodeModule>(module: Module, functor: () => never | void | Promise<any>): Module;
Type parameters
Name | Constraint |
---|---|
Module | NodeModule |
Parameters
Name | Type | Description |
---|---|---|
module | Module | NodeJS module |
functor | () => never | void | Promise | The function to execute. If undefined, module.exports is used. |
Return type
Module
Properties
Name | Type | Optional | Description |
---|---|---|---|
isLambda | boolean | false | True if the application is running as a lambda function |
isLocal | boolean | false | True if running in a local environment. |
isTesting | boolean | false | True if a unit test framework (jest, mocha) was detected. |
isGitRepo | boolean | false | True if the root application folder is a git repository (has .git and .gitignore) |
manifest | IPackageManifest | false | The root package.json manifest. |
env | ProcessEnv | false | The initial process.env |
initialCwd | string | false | The initial directory when the application was started. |
path | string | false | Gets or sets the application root path |
name | string | false | The application name as defined in the root package.json |
IPackageManifest
The definition of a NodeJS package.json manifest
interface IPackageManifest {
name: string;
version?: string | undefined;
description?: string | undefined;
keywords?: string[];
homepage?: string | undefined;
bugs?: string | { email: string; url: string; [key: string]: string | undefined; };
license?: string | undefined;
author?: string | { name: string; email?: string | undefined; homepage?: string | undefined; [key: string]: string | undefined; };
contributors?: string[] | { name: string; email?: string | undefined; homepage?: string | undefined; [key: string]: string | undefined; }[];
files?: string[];
main?: string | undefined;
bin?: string | { [name: string]: string | undefined; };
man?: string | string[];
directories?: { [key: string]: string | undefined; lib?: string | undefined; bin?: string | undefined; man?: st...;
repository?: string | { type: string; url: string; };
scripts?: { [scriptName: string]: string | undefined; } | undefined;
config?: { [key: string]: any; } | undefined;
dependencies?: { [name: string]: string | undefined; } | undefined;
devDependencies?: { [name: string]: string | undefined; } | undefined;
peerDependencies?: { [name: string]: string | undefined; } | undefined;
optionalDependencies?: { [name: string]: string | undefined; } | undefined;
bundledDependencies?: string[];
engines?: { [key: string]: string | undefined; node?: string | undefined; npm?: string | undefined; } | und...;
os?: string[];
cpu?: string[];
preferGlobal?: boolean | undefined;
private?: boolean | undefined;
publishConfig?: { [key: string]: string | undefined; registry?: string | undefined; } | undefined;
[key: string]: any;
}
Index
[key: string]: any;
- Parameter
key
- string - Type any
Properties
Name | Type | Optional | Description |
---|---|---|---|
name | string | false | Package name. Required. |
version | string | undefined | true | |
description | string | undefined | true | |
keywords | string[] | true | |
homepage | string | undefined | true | |
bugs | string | { email: string; url: string; [key: string]: string | undefined; } | true | |
license | string | undefined | true | |
author | string | { name: string; email?: string | undefined; homepage?: string | undefined; [key: string]: string | undefined; } | true | |
contributors | string[] | { name: string; email?: string | undefined; homepage?: string | undefined; [key: string]: string | undefined; }[] | true | |
files | string[] | true | |
main | string | undefined | true | |
bin | string | { [name: string]: string | undefined; } | true | |
man | string | string[] | true | |
directories | { [key: string]: string | undefined; lib?: string | undefined; bin?: string | undefined; man?: st... | true | |
repository | string | { type: string; url: string; } | true | |
scripts | { [scriptName: string]: string | undefined; } | undefined | true | |
config | { [key: string]: any; } | undefined | true | |
dependencies | { [name: string]: string | undefined; } | undefined | true | |
devDependencies | { [name: string]: string | undefined; } | undefined | true | |
peerDependencies | { [name: string]: string | undefined; } | undefined | true | |
optionalDependencies | { [name: string]: string | undefined; } | undefined | true | |
bundledDependencies | string[] | true | |
engines | { [key: string]: string | undefined; node?: string | undefined; npm?: string | undefined; } | und... | true | |
os | string[] | true | |
cpu | string[] | true | |
preferGlobal | boolean | undefined | true | |
private | boolean | undefined | true | |
publishConfig | { [key: string]: string | undefined; registry?: string | undefined; } | undefined | true |