Skip to content

Commit d2ce3f7

Browse files
committed
Add support for combining --circular and --dot
1 parent f9863aa commit d2ce3f7

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ madge('path/to/app.js').then((res) => {
175175
});
176176
```
177177

178-
#### .dot()
178+
#### .dot([circularOnly: boolean])
179179

180-
> Returns a `Promise` resolved with a DOT representation of the module dependency graph.
180+
> Returns a `Promise` resolved with a DOT representation of the module dependency graph. Set `circularOnly` to only include circular dependencies.
181181
182182
```javascript
183183
const madge = require('madge');

bin/cli.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ function createOutputFromOptions(program, res) {
248248
});
249249
}
250250

251+
if (program.dot) {
252+
return res.dot(program.circular).then((output) => {
253+
process.stdout.write(output);
254+
return res;
255+
});
256+
}
257+
251258
if (program.circular) {
252259
const circular = res.circular();
253260

@@ -261,11 +268,4 @@ function createOutputFromOptions(program, res) {
261268

262269
return res;
263270
}
264-
265-
if (program.dot) {
266-
return res.dot().then((output) => {
267-
process.stdout.write(output);
268-
return res;
269-
});
270-
}
271271
}

lib/api.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,15 @@ class Madge {
158158
/**
159159
* Return the module dependency graph as DOT output.
160160
* @api public
161+
* @param {Boolean} circularOnly
161162
* @return {Promise}
162163
*/
163-
dot() {
164-
return graph.dot(this.obj(), this.circular(), this.config);
164+
dot(circularOnly) {
165+
return graph.dot(
166+
circularOnly ? this.circularGraph() : this.obj(),
167+
this.circular(),
168+
this.config
169+
);
165170
}
166171

167172
/**

0 commit comments

Comments
 (0)