0.1.4 • Published 10 years ago

node-module-info v0.1.4

Weekly downloads
4
License
ISC
Repository
github
Last release
10 years ago

node-module-info npm versionBuild StatusCoverage Status

Full information about module in NodeJS.

Install

npm install node-module-info --save

Example

var getInfo = require("node-module-info");
getInfo("./module1", "/path/to/caller/");
getInfo("dependence1/file1", "/path/to/caller/");
getInfo("/absolute/file/of/module", "/path/to/caller/");
getInfo("/module/without/caller");

Usage

Lib supports:

getCallerInfo: () => Info; //return same info about caller
getFullPath: () => string; //get full path (resolved only for dependence)
getResolvedPath: () => string;  //resolve module path, throw error for non-existing
getRootPath: () => string; //root path of app (get first path, before first node_modules)
getPackagePath: () => string; //package path for current module
getRelativePath: () => string; //relative path from package path
getRelativeName: () => string; //relative path without extension
getDefineName: ()=>string;//name for use with builders, `npm!package@version#path`
isAbsoulte: () => boolean; //is module path absolute
isDependence: () => boolean; //is dependence of caller (if caller setted) or false
isRelative: () => boolean; //is starts with "." if caller setted, or if not absolute
isSystem: () => boolean; //if caller setted check for internal modules
getPackageInfo: () => { //info from package.json from package path
    name: string;
    version: string;
    ///...full info
};

Typings

export interface Info {
    getFullInfo: () => {
        fullPath: string,
        resolvedPath: string,
        rootPath: string,
        packagePath: string,
        relativePath: string,
        relativeName: string,
        defineName: string,
        isDependence: boolean,
        isSystem: boolean,
        isAbsolute: boolean,
        isRelative: boolean,
        packageInfo: Package,
        nearestPackageJSON: string
    },
    getCallerInfo: () => Info;
    getFullPath: () => string;
    getResolvedPath: () => string;
    getRootPath: () => string;
    getPackagePath: () => string;
    getRelativePath: () => string;
    getRelativeName: () => string;
    getDefineName: () => string;
    isAbsoulte: () => boolean;
    isDependence: () => boolean;
    isRelative: () => boolean;
    isSystem: () => boolean;
    getPackageInfo: () => Package;
}
export interface Package {
    name: string;
    version: string;
}

Tests

npm install
npm test
0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

1.0.0

10 years ago