// Using commonjs instead of ejs, because more widely compatible const inquirer = require( 'inquirer' ); const fs = require( 'fs' ); const path = require( 'path' ); const os = require( 'os' ); const render = require( './helpers/render' ); const { treeWalker } = require('./helpers/util'); // Prompt user to select a wallpaper (if no path is passed as argument) const wallpapers = treeWalker( path.join( os.homedir(), '/NextCloud/Wallpapers' ), '*' ); // const wallpapers = fs.readdirSync( path.join( os.homedir(), '/NextCloud/Wallpapers' ) ); const wallpaperChoices = []; wallpapers.forEach(element => { const name = element.split( '/' ); wallpaperChoices.push( { 'name': name[ name.length - 1 ].split( '.' )[ 0 ], 'value': element } ); }); // Selection options const chooseWallpaper = { 'type': 'list', 'name': 'wallpaper', 'message': 'Choose the wallpaper to be used', 'choices': wallpaperChoices, }; const chooseLockpaper = { 'type': 'list', 'name': 'lockpaper', 'message': 'Choose the lockscreen wallpaper to be used', 'choices': wallpaperChoices, }; const chooseTheme = { 'type': 'list', 'name': 'theme', 'message': 'Choose the general colourway to be used', 'choices': [ { name: 'Nordic', value: 'nordic' }, { name: 'Deep-Dark', value: 'deep-dark' }, { name: 'Material-You', value: 'material' }, { name: 'Light', value: 'light' }, { name: 'Bright', value: 'bright' }, ] } // TODO: Add argument parsing const args = process.argv.slice( 2 ); inquirer.default.prompt( [ chooseWallpaper, chooseLockpaper, chooseTheme ] ).then( answers => { render( answers.wallpaper, answers.lockpaper, answers.theme ); } ).catch( () => { process.exit( 1 ); } );