NPM CONFIG INFO
Get the config information stored by npm. This include the stored user details and folder information of the npm structure. Refer to change Logs for latest changes on the current version.
Install
npm install npm-config-info
Usage
const configInfo = ; let config = configInfoconfig;let user = configInfoauthorname;let email = configInfoauthoremail;let npmFolder = configInfofoldersprefix;
The code could also run asynchronously:
let configInfo; ;
Global Store
Please note that the global values could also be obtained by calling getGlobal() from the returned object.
We will attempt to figure out where the npmrc file resides.
A string variable of where the global npmrc file could be found could also be provided in getGlobal e.g.:
const configInfo globState = ; let config = configInfo;let globalAuthor; configInfo; if configInfoglobalState === globStateInitialized globalAuthor = configInfoglobalauthor; // ORif configInfoglobalState !== globStateNotFound && configInfoglobalState !== globStateNotInitialized globalAuthor = configInfoglobalauthor;
The global variables can also be created by the constructor:
PLEASE NOTE: although the state could be found on the global object (for now and if global has not been initialized or found). The correct state checking should happen through globalState property
const configInfo = ;console;
NPMRC
Please have a look at npm of how the data is usually resolved.
Contributions
Contributions are welcome. This was a quick project as I required an easy way to access the stored author creditials from javascript.
Change Log
- Fixed Readme spelling errors.
- Added a globalState variable to ConfigInfo (we should have done so from the start). For the moment global will still be an object or the value of globalState if no object could be found. String value on global property is preserved for now, but should not be used. For checking use globalState variable. State on "global" will be removed in future.
- Added an "enum" globaState to both index.js and ConfInfo.js.
0.1.1
- Fixing intelisense (d.ts) file for the enum globState.