@@ -275,7 +275,8 @@ class TargetNode {
275275 constructor (
276276 public target : Target ,
277277 private folder : FolderContext ,
278- private activeTasks : Set < string >
278+ private activeTasks : Set < string > ,
279+ private fs ?: ( folder : string ) => Promise < string [ ] >
279280 ) { }
280281
281282 get name ( ) : string {
@@ -363,68 +364,24 @@ class TargetNode {
363364 // .build/plugins/outputs/buildtoolplugin/<target-name>/destination/<build-tool-plugin-name>/*
364365 // This glob will capture all the files in the outputs directory for this target.
365366 const pattern = this . buildToolGlobPattern ( version ) ;
366- const matches = glob . sync ( pattern , { onlyDirectories : false } ) ;
367-
368- const buildTree = ( matches : string [ ] ) : TreeNode [ ] => {
369- const basePath = path . join ( this . folder . folder . fsPath , ".build" , "plugins" , "outputs" ) ;
370- // Gather up the files by build tool plugin name. Don't capture any more files than
371- // just the build-tool-plugin-name folder, as the FileNode will handle walking the tree.
372- const buildToolPluginFiles = matches . reduce (
373- ( memo , filePath ) => {
374- const relativePath = path . relative ( basePath , filePath ) ;
375- const parts = relativePath . split ( path . sep ) ;
376- const buildToolPluginName = version . isGreaterThanOrEqual (
377- this . newPluginLayoutVersion
378- )
379- ? parts [ 3 ]
380- : parts [ 2 ] ;
381- const existingFiles = memo [ buildToolPluginName ] || [ ] ;
382- const rootDirectoryLength = version . isGreaterThanOrEqual (
383- this . newPluginLayoutVersion
367+ const base = this . folder . folder . fsPath . replace ( / \\ / g, "/" ) ;
368+ const matches = glob . sync ( pattern , { onlyFiles : false , cwd : base , deep : 4 } ) ;
369+
370+ return matches . map ( filePath => {
371+ const pluginName = path . basename ( filePath ) ;
372+ return new HeaderNode (
373+ `${ this . target . name } -${ pluginName } ` ,
374+ `${ pluginName } - Generated Files` ,
375+ "debug-disconnect" ,
376+ ( ) =>
377+ getChildren (
378+ filePath ,
379+ excludedFilesForProjectPanelExplorer ( ) ,
380+ this . target . path ,
381+ this . fs
384382 )
385- ? 5
386- : 4 ;
387- const isRootPluginFilesDirectory = parts . length === rootDirectoryLength ;
388- return {
389- ...memo ,
390- [ buildToolPluginName ] : isRootPluginFilesDirectory
391- ? [ ...existingFiles , filePath ]
392- : existingFiles ,
393- } ;
394- } ,
395- { } as Record < string , string [ ] >
396383 ) ;
397-
398- // Create a new HeaderNode for each build tool plugin used to generate files for this target.
399- return Object . keys ( buildToolPluginFiles )
400- . map ( pluginName => {
401- const pluginFiles = buildToolPluginFiles [ pluginName ] ;
402- if ( pluginFiles . length === 0 ) {
403- return undefined ;
404- }
405- return new HeaderNode (
406- `${ this . target . name } -${ pluginName } ` ,
407- `${ pluginName } - Generated Files` ,
408- "debug-disconnect" ,
409- ( ) => {
410- return Promise . all (
411- pluginFiles . map ( async filePath => {
412- const stats = await fs . stat ( filePath ) ;
413- return new FileNode (
414- path . basename ( filePath ) ,
415- filePath ,
416- stats . isDirectory ( ) ,
417- `${ this . target . name } -${ pluginName } `
418- ) ;
419- } )
420- ) ;
421- }
422- ) ;
423- } )
424- . filter ( ( node ) : node is HeaderNode => node !== undefined ) ;
425- } ;
426-
427- return matches . length > 0 ? buildTree ( matches ) : [ ] ;
384+ } ) ;
428385 }
429386}
430387
0 commit comments