npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

get-app-root-path

v0.0.20

Published

Get the root folder of the running node application

Downloads

183

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

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 | |