@@ -33,7 +33,9 @@ module.exports = function(options) {
3333 return config . isListForm ? [ ] : { } ;
3434 }
3535
36- const results = traverse ( config ) ;
36+ const params = { treePath : [ ] } ;
37+
38+ const results = traverse ( config , params ) ;
3739 debug ( 'traversal complete' , results ) ;
3840
3941 dedupeNonExistent ( config . nonExistent ) ;
@@ -81,10 +83,11 @@ module.exports.toList = function(options) {
8183 * @param {Config } config
8284 * @return {Array }
8385 */
84- module . exports . _getDependencies = function ( config ) {
86+ module . exports . _getDependencies = function ( config , params ) {
8587 let dependencies ;
8688 const precinctOptions = config . detectiveConfig ;
8789 precinctOptions . includeCore = false ;
90+ precinctOptions . treePath = params . treePath ;
8891
8992 try {
9093 dependencies = precinct . paperwork ( config . filename , precinctOptions ) ;
@@ -136,9 +139,10 @@ module.exports._getDependencies = function(config) {
136139
137140/**
138141 * @param {Config } config
142+ * @param {Object } params
139143 * @return {Object|Set }
140144 */
141- function traverse ( config ) {
145+ function traverse ( config , params ) {
142146 let subTree = config . isListForm ? new Set ( ) : { } ;
143147
144148 debug ( 'traversing ' + config . filename ) ;
@@ -148,7 +152,7 @@ function traverse(config) {
148152 return config . visited [ config . filename ] ;
149153 }
150154
151- let dependencies = module . exports . _getDependencies ( config ) ;
155+ let dependencies = module . exports . _getDependencies ( config , params ) ;
152156
153157 debug ( 'cabinet-resolved all dependencies: ' , dependencies ) ;
154158 // Prevents cycles by eagerly marking the current file as read
@@ -169,12 +173,17 @@ function traverse(config) {
169173 const localConfig = config . clone ( ) ;
170174 localConfig . filename = d ;
171175
176+ const newParams = {
177+ ...params ,
178+ treePath : [ ...( params . treePath ? params . treePath : [ ] ) , config . filename ]
179+ }
180+
172181 if ( localConfig . isListForm ) {
173- for ( let item of traverse ( localConfig ) ) {
182+ for ( let item of traverse ( localConfig , newParams ) ) {
174183 subTree . add ( item ) ;
175184 }
176185 } else {
177- subTree [ d ] = traverse ( localConfig ) ;
186+ subTree [ d ] = traverse ( localConfig , newParams ) ;
178187 }
179188 }
180189
0 commit comments