diff --git a/README.md b/README.md index 9fa64f95..ab9fd4ff 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,9 @@ Property | Type | Default | Description `detectiveOptions` | Object | false | Custom `detective` options for [dependency-tree](https://github.com/dependents/node-dependency-tree) and [precinct](https://github.com/dependents/node-precinct#usage) `dependencyFilter` | Function | false | Function called with a dependency filepath (exclude substree by returning false) -> Note that when running the CLI it's possible to use a runtime configuration file. The config should placed in `.madgerc` in your project or home folder. Look [here](https://github.com/dominictarr/rc#standards) for alternative locations for the file. Here's an example: +You can use configuration file either in `.madgerc` in your project or home folder or directly in `package.json`. Look [here](https://github.com/dominictarr/rc#standards) for alternative locations for the file. + +> .madgerc ```json { @@ -233,6 +235,23 @@ Property | Type | Default | Description } ``` +> package.json +```json +{ + "name": "foo", + "version": "0.0.1", + ... + "madge": { + "fontSize": "10px", + "graphVizOptions": { + "G": { + "rankdir": "LR" + } + } + } +} +``` + # CLI ## Examples diff --git a/bin/cli.js b/bin/cli.js index 8d3f0302..e87d888f 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -51,7 +51,12 @@ if (!program.color) { const log = require('../lib/log'); const output = require('../lib/output'); const madge = require('../lib/api'); -const config = Object.assign({}, rc); + +let packageConfig = {}; +try { + packageConfig = require(path.join(process.cwd(), 'package.json')).madge; +} catch (e) { } +const config = Object.assign(rc, packageConfig); program.options.forEach((opt) => { const name = opt.name();