module-info
v1.2.3
Published
[ABANDONED] Find package.json files in module and load information from it
Downloads
18
Readme
module-info
Find package.json files in module and load information from it.
Help
Unfortunately I don't have any more time to maintain this repository :-(
Don't you want to save me and this project by taking over it?
Installation
$ npm install module-info
Usage
Base option is to set base directory of module.
var Info = require('module-info');
var info = new Info('/path/to/some/module');
Find from file in module
If you have got some file somewhere in module directory tree, module-info can find information about module automatically.
var info = Info.fromFile('/path/to/some/module/and/some/file/in/it.js');
Find by name (in node_modules)
You can search for information about some module on which your module is dependent.
var info = Info.fromName(module, 'dependent-module');
Find for your module
This option is similar for example to package pkginfo.
var info = Info.self(module);
Info object
getPackagePath()
: returns path topackage.json
filegetData()
: returns parsed JSON data frompackage.json
filegetName()
: returns name of modulegetPath()
: returns resolved path to modulegetVersion()
: returns version of modulegetMainFile()
: returns resolved full path to main file (even it is not defined inpackage.json
)getModuleName(string filePath, bool relative = false)
: returns name for file in module used inrequire
methodisNpmDependency()
: return true if module is dependency for another moduleisFileInModule(string filePath)
: checks if file is in module directory (not in any dependent sub-module)
Tests
$ npm test
Changelog
1.2.3
- Move under Carrooi organization
- Abandon package
1.2.2
- Bug with giving name of some files
1.2.1
getModuleName
can return name relatively to base module directory
1.2.0
- Added method
isNpmDependency
- Added method
isFileInModule
- Method
getModuleName
throw an error if file is not in module - Some refactoring in tests
- Added method
1.1.2
- Just typo in readme
1.1.11
- If main section in package.json is not defined and file
./index.js
exists, it will be returned fromgetMainFile
method - Method
getPackageData
renamed togetData
- Method
getPackageData
is now deprecated
- If main section in package.json is not defined and file
1.1.0
- Added getPath method
- Added getModuleName method
1.0.0
- First version