Package Exports
- check-dependencies
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (check-dependencies) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
check-dependencies
Checks if currently installed npm dependencies are installed in the exact same versions that are specified in package.json.
(Note: the package previously published under this name is now called dependency-status)
Installation
To install the package and add it to your package.json, invoke:
npm install check-dependencies --save-devRationale
When dependencies are changed in package.json, whether it's a version bump or a new package, one can forget to invoke npm install and continue using the application, possibly encountering errors caused by obsolete package versions. To avoid it, use the check-dependencies module at the top of the entry point of your application; it will inform about not up-to-date setup and optionally install the dependencies.
Another option would be to always invoke npm install at the top of the main file but npm install can be slow and check-dependencies is fast.
Usage
Once the package has been installed, it may be used via:
require('check-dependencies')(config, callback);where callback is invoked upon completion and config is a configuration object.
callback is invoked with the object containing fields:
{
status: number, // 0 if successful, 1 otherwise
output: array, // array of logged messages
error: array, // array of logged errors
} log and error - arrays aggregating informational and error
messages. The operation was successful if
The config object can have the following fields:
packageDir
Path to the directory containing package.json.
Type: string
Default: the closest directory containing package.json when going up the tree, starting from the current one
install
Installs packages if they don't match.
Type: boolean
Default: false
scopeList
The list of keys in package.json where to look for package names & versions.
Type: array
Default: ['dependencies', 'devDependencies']
verbose
Prints messages to the console.
Type: boolean
Default: false
log
A function logging debug messages.
Type: function
Default: console.log.bind(console)
error
A function logging error messages.
Type: function
Default: console.error.bind(console)
Usage Examples
The most basic usage:
require('check-dependencies')(callback);This will check packages' versions, install mismatched ones and invoke callback.
The following:
require('check-dependencies')({
install: false,
error: true,
}, callback);will report an error to callback if packages' versions are mismatched.
The following two examples:
require('check-dependencies')(callback);
require('check-dependencies')({}, callback);behave in the same way - callback is invoked upon completion; if there was an error, it's passed as a parameter to callback.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using npm test.
License
Copyright (c) 2014 Michał Gołębiowski. Licensed under the MIT license.