[Build] Improve treeWalker, renderer & wallpaper finder

This commit is contained in:
2025-03-29 10:30:08 +01:00
parent 527f2012de
commit c9442acce8
4 changed files with 31 additions and 21 deletions

View File

@@ -57,13 +57,13 @@ const build = ( wallpaper, lockpaper, theme ) => {
// recursively index files from config directory -> Maybe add a file to each
// directory to indicate whether or not to index files in it?
const fileList = util.treeWalker( path.join( __dirname, '/../config/' ), '*' );
const fileList = util.treeWalker( path.join( __dirname, '/../config/' ), '*', [ 'node_modules', '@girs', '.gitignore', '.git' ] );
console.log( fileList );
for (let index = 0; index < fileList; index++) {
for (let index = 0; index < fileList.length; index++) {
try {
render( fileList[ index ], view );
} catch ( e ) {
console.error( '=> Render failed for ' + fileList[ index ] );
console.error( '=> Render failed for ' + fileList[ index ] + ' with error ' + e );
}
}
} ).catch( e => {
@@ -136,13 +136,16 @@ const yaziThemes = {
*/
const render = ( templatePath, view ) => {
// Load template from disk (all can be found in <project-root>/config)
const template = '' + fs.readFileSync( path.join( __dirname, '/../config/', templatePath ) );
const outPath = path.join( __dirname, 'dist', templatePath )
// TODO: Make exclusion better plus copy other files maybe?
const template = '' + fs.readFileSync( templatePath );
const outPath = path.join( templatePath.replace( 'config', 'dist' ) );
console.log( '=> Rendering to ' + outPath );
try {
fs.mkdir( path.dirname( outPath ) );
} catch ( _ ) {
fs.mkdirSync( path.dirname( outPath ), {
recursive: true,
} );
} catch ( e ) {
console.error( e );
}
fs.writeFileSync( outPath, mustache.render( template, view ) );
}