0.0.20 • Published 5 years ago

get-app-root-path v0.0.20

Weekly downloads
108
License
MIT
Repository
github
Last release
5 years ago

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

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

NameTypeDescription
valuestring | booleanThe boolean value.

Return type

void

getIsTesting(): boolean;

Return type

boolean

setIsTesting(value: string | boolean): void;

Parameters

NameTypeDescription
valuestring | booleanThe boolean value.

Return type

void

getPath(): string;

Return type

string

setPath(value: string): void;

Parameters

NameTypeDescription
valuestringThe new root folder path.

Return type

void

shortenPath(p: string, rootDir?: string | undefined): string;

Parameters

NameTypeDescription
pstringThe path to shorten.
rootDirstring | undefinedThe root dir, by default is getAppRootPath()

Return type

string

coreModule<Module extends NodeModule>(module: Module): Module;

Type parameters

NameConstraint
ModuleNodeModule

Parameters

NameTypeDescription
moduleModuleNodeJS module

Return type

Module

executableModule<Module extends NodeModule>(module: Module, functor: () => never | void | Promise<any>): Module;

Type parameters

NameConstraint
ModuleNodeModule

Parameters

NameTypeDescription
moduleModuleNodeJS module
functor() => never | void | PromiseThe function to execute. If undefined, module.exports is used.

Return type

Module

Properties

NameTypeOptionalDescription
isLambdabooleanfalseTrue if the application is running as a lambda function
isLocalbooleanfalseTrue if running in a local environment.
isTestingbooleanfalseTrue if a unit test framework (jest, mocha) was detected.
isGitRepobooleanfalseTrue if the root application folder is a git repository (has .git and .gitignore)
manifestIPackageManifestfalseThe root package.json manifest.
envProcessEnvfalseThe initial process.env
initialCwdstringfalseThe initial directory when the application was started.
pathstringfalseGets or sets the application root path
namestringfalseThe 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

NameTypeOptionalDescription
namestringfalsePackage name. Required.
versionstring | undefinedtrue
descriptionstring | undefinedtrue
keywordsstring[]true
homepagestring | undefinedtrue
bugsstring | { email: string; url: string; key: string: string | undefined; }true
licensestring | undefinedtrue
authorstring | { name: string; email?: string | undefined; homepage?: string | undefined; key: string: string | undefined; }true
contributorsstring[] | { name: string; email?: string | undefined; homepage?: string | undefined; key: string: string | undefined; }[]true
filesstring[]true
mainstring | undefinedtrue
binstring | { name: string: string | undefined; }true
manstring | string[]true
directories{ key: string: string | undefined; lib?: string | undefined; bin?: string | undefined; man?: st...true
repositorystring | { type: string; url: string; }true
scripts{ scriptName: string: string | undefined; } | undefinedtrue
config{ key: string: any; } | undefinedtrue
dependencies{ name: string: string | undefined; } | undefinedtrue
devDependencies{ name: string: string | undefined; } | undefinedtrue
peerDependencies{ name: string: string | undefined; } | undefinedtrue
optionalDependencies{ name: string: string | undefined; } | undefinedtrue
bundledDependenciesstring[]true
engines{ key: string: string | undefined; node?: string | undefined; npm?: string | undefined; } | und...true
osstring[]true
cpustring[]true
preferGlobalboolean | undefinedtrue
privateboolean | undefinedtrue
publishConfig{ key: string: string | undefined; registry?: string | undefined; } | undefinedtrue
0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago