@@ -289,7 +289,8 @@ class TargetNode {
289289 constructor (
290290 public target : Target ,
291291 private folder : FolderContext ,
292- private activeTasks : Set < string >
292+ private activeTasks : Set < string > ,
293+ private fs ?: ( folder : string ) => Promise < string [ ] >
293294 ) { }
294295
295296 get name ( ) : string {
@@ -377,68 +378,24 @@ class TargetNode {
377378 // .build/plugins/outputs/buildtoolplugin/<target-name>/destination/<build-tool-plugin-name>/*
378379 // This glob will capture all the files in the outputs directory for this target.
379380 const pattern = this . buildToolGlobPattern ( version ) ;
380- const matches = glob . sync ( pattern , { onlyDirectories : false } ) ;
381-
382- const buildTree = ( matches : string [ ] ) : TreeNode [ ] => {
383- const basePath = path . join ( this . folder . folder . fsPath , ".build" , "plugins" , "outputs" ) ;
384- // Gather up the files by build tool plugin name. Don't capture any more files than
385- // just the build-tool-plugin-name folder, as the FileNode will handle walking the tree.
386- const buildToolPluginFiles = matches . reduce (
387- ( memo , filePath ) => {
388- const relativePath = path . relative ( basePath , filePath ) ;
389- const parts = relativePath . split ( path . sep ) ;
390- const buildToolPluginName = version . isGreaterThanOrEqual (
391- this . newPluginLayoutVersion
392- )
393- ? parts [ 3 ]
394- : parts [ 2 ] ;
395- const existingFiles = memo [ buildToolPluginName ] || [ ] ;
396- const rootDirectoryLength = version . isGreaterThanOrEqual (
397- this . newPluginLayoutVersion
381+ const base = this . folder . folder . fsPath . replace ( / \\ / g, "/" ) ;
382+ const matches = glob . sync ( pattern , { onlyFiles : false , cwd : base , deep : 4 } ) ;
383+
384+ return matches . map ( filePath => {
385+ const pluginName = path . basename ( filePath ) ;
386+ return new HeaderNode (
387+ `${ this . target . name } -${ pluginName } ` ,
388+ `${ pluginName } - Generated Files` ,
389+ "debug-disconnect" ,
390+ ( ) =>
391+ getChildren (
392+ filePath ,
393+ excludedFilesForProjectPanelExplorer ( ) ,
394+ this . target . path ,
395+ this . fs
398396 )
399- ? 5
400- : 4 ;
401- const isRootPluginFilesDirectory = parts . length === rootDirectoryLength ;
402- return {
403- ...memo ,
404- [ buildToolPluginName ] : isRootPluginFilesDirectory
405- ? [ ...existingFiles , filePath ]
406- : existingFiles ,
407- } ;
408- } ,
409- { } as Record < string , string [ ] >
410397 ) ;
411-
412- // Create a new HeaderNode for each build tool plugin used to generate files for this target.
413- return Object . keys ( buildToolPluginFiles )
414- . map ( pluginName => {
415- const pluginFiles = buildToolPluginFiles [ pluginName ] ;
416- if ( pluginFiles . length === 0 ) {
417- return undefined ;
418- }
419- return new HeaderNode (
420- `${ this . target . name } -${ pluginName } ` ,
421- `${ pluginName } - Generated Files` ,
422- "debug-disconnect" ,
423- ( ) => {
424- return Promise . all (
425- pluginFiles . map ( async filePath => {
426- const stats = await fs . stat ( filePath ) ;
427- return new FileNode (
428- path . basename ( filePath ) ,
429- filePath ,
430- stats . isDirectory ( ) ,
431- `${ this . target . name } -${ pluginName } `
432- ) ;
433- } )
434- ) ;
435- }
436- ) ;
437- } )
438- . filter ( ( node ) : node is HeaderNode => node !== undefined ) ;
439- } ;
440-
441- return matches . length > 0 ? buildTree ( matches ) : [ ] ;
398+ } ) ;
442399 }
443400}
444401
0 commit comments