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