@@ -33,7 +33,9 @@ module.exports = function(options) {
33
33
return config . isListForm ? [ ] : { } ;
34
34
}
35
35
36
- const results = traverse ( config ) ;
36
+ const params = { treePath : [ ] } ;
37
+
38
+ const results = traverse ( config , params ) ;
37
39
debug ( 'traversal complete' , results ) ;
38
40
39
41
dedupeNonExistent ( config . nonExistent ) ;
@@ -81,10 +83,11 @@ module.exports.toList = function(options) {
81
83
* @param {Config } config
82
84
* @return {Array }
83
85
*/
84
- module . exports . _getDependencies = function ( config ) {
86
+ module . exports . _getDependencies = function ( config , params ) {
85
87
let dependencies ;
86
88
const precinctOptions = config . detectiveConfig ;
87
89
precinctOptions . includeCore = false ;
90
+ precinctOptions . treePath = params . treePath ;
88
91
89
92
try {
90
93
dependencies = precinct . paperwork ( config . filename , precinctOptions ) ;
@@ -136,9 +139,10 @@ module.exports._getDependencies = function(config) {
136
139
137
140
/**
138
141
* @param {Config } config
142
+ * @param {Object } params
139
143
* @return {Object|Set }
140
144
*/
141
- function traverse ( config ) {
145
+ function traverse ( config , params ) {
142
146
let subTree = config . isListForm ? new Set ( ) : { } ;
143
147
144
148
debug ( 'traversing ' + config . filename ) ;
@@ -148,7 +152,7 @@ function traverse(config) {
148
152
return config . visited [ config . filename ] ;
149
153
}
150
154
151
- let dependencies = module . exports . _getDependencies ( config ) ;
155
+ let dependencies = module . exports . _getDependencies ( config , params ) ;
152
156
153
157
debug ( 'cabinet-resolved all dependencies: ' , dependencies ) ;
154
158
// Prevents cycles by eagerly marking the current file as read
@@ -169,12 +173,17 @@ function traverse(config) {
169
173
const localConfig = config . clone ( ) ;
170
174
localConfig . filename = d ;
171
175
176
+ const newParams = {
177
+ ...params ,
178
+ treePath : [ ...( params . treePath ? params . treePath : [ ] ) , config . filename ]
179
+ }
180
+
172
181
if ( localConfig . isListForm ) {
173
- for ( let item of traverse ( localConfig ) ) {
182
+ for ( let item of traverse ( localConfig , newParams ) ) {
174
183
subTree . add ( item ) ;
175
184
}
176
185
} else {
177
- subTree [ d ] = traverse ( localConfig ) ;
186
+ subTree [ d ] = traverse ( localConfig , newParams ) ;
178
187
}
179
188
}
180
189
0 commit comments