[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

@@ -4,13 +4,16 @@ const fs = require( 'fs' );
const path = require( 'path' );
const os = require( 'os' );
const render = require( './render' );
const { treeWalker } = require('./util');
// Prompt user to select a wallpaper (if no path is passed as argument)
const wallpapers = fs.readdirSync( path.join( os.homedir(), '/NextCloud/Wallpapers' ) );
const wallpapers = treeWalker( path.join( os.homedir(), '/NextCloud/Wallpapers' ), '*' );
// const wallpapers = fs.readdirSync( path.join( os.homedir(), '/NextCloud/Wallpapers' ) );
const wallpaperChoices = [];
wallpapers.forEach(element => {
wallpaperChoices.push( { 'name': element.split( '.' )[ 0 ], 'value': element } );
const name = element.split( '/' );
wallpaperChoices.push( { 'name': name[ name.length - 1 ].split( '.' )[ 0 ], 'value': element } );
});
@@ -49,5 +52,5 @@ inquirer.default.prompt( [
chooseLockpaper,
chooseTheme
] ).then( answers => {
render( path.join( os.homedir(), '/NextCloud/Wallpapers', answers.wallpaper ), path.join( os.homedir(), '/NextCloud/Wallpapers', answers.lockpaper ), answers.theme );
render( answers.wallpaper, answers.lockpaper, answers.theme );
} );