[Build] Improve rendering, add fs parsing

FS parsing needs a lot of improvements (namely ignoring gitignore
files). Probably gonna migrate to a library for this
This commit is contained in:
2025-03-25 20:06:50 +01:00
parent bab328c2d3
commit c2f38bc39a
3 changed files with 22 additions and 42 deletions

View File

@@ -50,7 +50,7 @@ const build = ( wallpaper, lockpaper, theme ) => {
console.log( view );
try {
fs.mkdir( path.join( __dirname + '../dist' ) );
fs.mkdir( path.join( __dirname, '/dist' ) );
} catch ( e ) {
}
@@ -58,6 +58,7 @@ 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/' ), '*' );
console.log( fileList );
for (let index = 0; index < fileList; index++) {
try {
render( fileList[ index ], view );
@@ -65,7 +66,8 @@ const build = ( wallpaper, lockpaper, theme ) => {
console.error( '=> Render failed for ' + fileList[ index ] );
}
}
} ).catch( () => {
} ).catch( e => {
console.error( e );
console.error( '\n=> Failed to load image or retrieve colour palette from it' );
} );
}
@@ -135,7 +137,13 @@ 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 = '';
const outPath = path.join( __dirname, 'dist', templatePath )
console.log( '=> Rendering to ' + outPath );
try {
fs.mkdir( path.dirname( outPath ) );
} catch ( _ ) {
}
fs.writeFileSync( outPath, mustache.render( template, view ) );
}