[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:
@@ -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 ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user