@@ -13,7 +13,7 @@ import {
1313 SEP ,
1414} from "../deno_ral/path.ts" ;
1515
16- import { existsSync , walkSync } from "../deno_ral/fs.ts" ;
16+ import { existsSync , walk , walkSync } from "../deno_ral/fs.ts" ;
1717import * as ld from "../core/lodash.ts" ;
1818
1919import { ProjectType } from "./types/types.ts" ;
@@ -99,6 +99,7 @@ import { computeProjectEnvironment } from "./project-environment.ts";
9999import { ProjectEnvironment } from "./project-environment-types.ts" ;
100100import { NotebookContext } from "../render/notebook/notebook-types.ts" ;
101101import { MappedString } from "../core/mapped-text.ts" ;
102+ import { makeTimedFunctionAsync } from "../core/performance/function-times.ts" ;
102103import { createProjectCache } from "../core/cache/cache.ts" ;
103104import { createTempContext , globalTempContext } from "../core/temp.ts" ;
104105
@@ -750,7 +751,12 @@ function projectHiddenIgnoreGlob(dir: string) {
750751 . concat ( [ "**/README.?([Rrq])md" ] ) ; // README
751752}
752753
753- export async function projectInputFiles (
754+ export const projectInputFiles = makeTimedFunctionAsync (
755+ "projectInputFiles" ,
756+ projectInputFilesInternal ,
757+ ) ;
758+
759+ async function projectInputFilesInternal (
754760 project : ProjectContext ,
755761 metadata ?: ProjectConfig ,
756762) : Promise < { files : string [ ] ; engines : string [ ] } > {
@@ -802,10 +808,9 @@ export async function projectInputFiles(
802808 } ] ;
803809 } ;
804810 const addDir = async ( dir : string ) : Promise < FileInclusion [ ] > => {
805- // ignore selected other globs
806- const walkIterator = walkSync (
807- dir ,
808- {
811+ const promises : Promise < FileInclusion [ ] > [ ] = [ ] ;
812+ for await (
813+ const walkEntry of walk ( dir , {
809814 includeDirs : false ,
810815 // this was done b/c some directories e.g. renv/packrat and potentially python
811816 // virtualenvs include symblinks to R or Python libraries that are in turn
@@ -816,16 +821,18 @@ export async function projectInputFiles(
816821 globToRegExp ( join ( dir , ignore ) + SEP )
817822 ) ,
818823 ) ,
819- } ,
820- ) ;
821- return Promise . all (
822- Array . from ( walkIterator )
823- . filter ( ( walk ) => {
824- const pathRelative = pathWithForwardSlashes ( relative ( dir , walk . path ) ) ;
825- return ! projectIgnores . some ( ( regex ) => regex . test ( pathRelative ) ) ;
826- } )
827- . map ( async ( walk ) => addFile ( walk . path ) ) ,
828- ) . then ( ( fileInclusions ) => fileInclusions . flat ( ) ) ;
824+ } )
825+ ) {
826+ const pathRelative = pathWithForwardSlashes (
827+ relative ( dir , walkEntry . path ) ,
828+ ) ;
829+ if ( projectIgnores . some ( ( regex ) => regex . test ( pathRelative ) ) ) {
830+ continue ;
831+ }
832+ promises . push ( addFile ( walkEntry . path ) ) ;
833+ }
834+ const inclusions = await Promise . all ( promises ) ;
835+ return inclusions . flat ( ) ;
829836 } ;
830837 const addEntry = async ( entry : string ) => {
831838 if ( Deno . statSync ( entry ) . isDirectory ) {
0 commit comments