nl_tokens: Scans a folder recursively looking for resource files
pl_tokens: function scanDir ( rootDir , dir , resource , doNotCopy , callback ) { // Get the list of files fs . readdir ( dir , function ( err , files ) { if ( err ) { callback ( err ) ; return ; } // and process each one async . forEach ( <mask> , function ( file , callback ) { var absFile = path . join ( dir , file ) ; fs . stat ( absFile , function ( err , stat ) { if ( err ) { callback ( err ) ; return ; } // Directory? recurse if ( stat . isDirectory ( ) ) { scanDir ( rootDir , absFile , resource , doNotCopy , callback ) ; } else { var relFile = absFile . substring ( rootDir . length + 1 ) . replace ( / \\ / g , "/" ) ; var fileInfo = resources [ relFile ] ; delete unconfirmed [ relFile ] ; if ( ! fileInfo ) { fileInfo = resources [ relFile ] = { } ; } fileInfo . doNotCopy = doNotCopy ; fileInfo . resource = resource ; t . __librariesByResourceUri [ relFile ] = library ; var relDir = dir . substring ( rootDir . length + 1 ) . replace ( / \\ / g , "/" ) ; t . __librariesByResourceFolderUri [ relDir ] = library ; var tmp = "" ; relDir . split ( "/" ) . forEach ( seg => { if ( tmp . length ) { tmp += "/" ; } tmp += seg ; t . __librariesByResourceFolderUri [ tmp ] = library ; } ) ; var handlers = t . __handlers . filter ( handler => handler . matches ( absFile ) ) ; if ( ! handlers . length ) { callback ( ) ; return ; } if ( handlers . some ( handler => handler . needsCompile ( absFile , fileInfo , stat ) ) ) { fileInfo . mtime = stat . mtime ; tasks . push ( { fileInfo : fileInfo , absFile : absFile , library : library , handlers : handlers } ) ; } callback ( ) ; } } ) ; } , callback ) ; } ) ; }