[Build] Improve treeWalker, renderer & wallpaper finder
This commit is contained in:
@@ -3,27 +3,27 @@ const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
/**
|
||||
* Recursively find all HTML files in a directory
|
||||
* Recursively find all files with extension in a directory
|
||||
* @param {string} dir The directory to search. Either absolute or relative path
|
||||
* @param {string} extension The file extension to look for
|
||||
* @returns {string[]} returns a list of html files with their full path
|
||||
*/
|
||||
const treeWalker = ( dir, extension ) => {
|
||||
const treeWalker = ( dir, extension, ignoreList ) => {
|
||||
const ls = fs.readdirSync( dir );
|
||||
const fileList = [];
|
||||
for ( let file in ls ) {
|
||||
if ( fs.statSync( path.join( dir, ls[ file ] ) ).isDirectory() ) {
|
||||
const newFiles = treeWalker( path.join( dir, ls[ file ] ), extension );
|
||||
// TODO: Ignore files in .gitignore, as well as .gitignore
|
||||
if ( !newFiles.includes( '.configbuildignore' ) ) {
|
||||
for ( let file in newFiles ) {
|
||||
// Filter ignored directories
|
||||
if ( ignoreList === undefined || !ignoreList.includes( ls[ file ] ) ) {
|
||||
const newFiles = treeWalker( path.join( dir, ls[ file ] ), extension, ignoreList );
|
||||
for (let file = 0; file < newFiles.length; file++) {
|
||||
fileList.push( newFiles[ file ] );
|
||||
}
|
||||
}
|
||||
} else if ( extension == '*' ) {
|
||||
fileList.push( path.join( dir, ls[ file ] ) );
|
||||
} else if ( ls[ file ].includes( extension ) ) {
|
||||
fileList.push( path.join( dir, ls[ file ] ) );
|
||||
} else if ( extension == '*' || ls[ file ].includes( extension ) ) {
|
||||
if ( ignoreList === undefined || !ignoreList.includes( ls[ file ] ) ) {
|
||||
fileList.push( path.join( dir, ls[ file ] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user