From 2ccb55c08f5d75483dd0f643b9f5ac1a85c73561 Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 17 Feb 2021 13:51:02 +0100 Subject: [PATCH] cli/launcher: add file browser button for the `theme` option and fix parsing path containing spaces if only one theme is set --- CHANGELOG.md | 3 +++ src/server/options.js | 2 +- src/server/theme.js | 22 +++++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0a9a74b..28d8dc54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ # 1.8.8 +- launcher + - add file browser button for the `theme` option and fix parsing path containing spaces if only one theme is set + - windows - remove `ctrl+w` shortcut for closing a window (use `alt+f4` instead) diff --git a/src/server/options.js b/src/server/options.js index 3ed2f445..2373da2d 100644 --- a/src/server/options.js +++ b/src/server/options.js @@ -58,7 +58,7 @@ module.exports = { 'd': {alias: 'debug', type: 'boolean', describe: 'log received osc messages in the console'}, 'n': {alias: 'no-gui', type: 'boolean', describe: 'disable default gui'}, 'fullscreen': {type: 'boolean', describe: 'launch in fullscreen mode (only affects the default client gui)'}, - 't': {alias: 'theme', type: 'array', describe: 'theme name or path (multiple values allowed)'}, + 't': {alias: 'theme', type: 'array', file: {name: 'css file (.css)', extensions: ['css']}, describe: 'theme name or path (multiple values allowed)'}, 'client-options': {type: 'array', describe: 'client options (opt=value pairs)', check: (o)=>{ return o.some(item=>!item.match(/^[^=]*=[^=]*$/)) ? diff --git a/src/server/theme.js b/src/server/theme.js index 3140d31a..7119eccf 100644 --- a/src/server/theme.js +++ b/src/server/theme.js @@ -25,15 +25,23 @@ class Theme { if (!this.themes.length) return this - for (let theme of this.themes) { + if (this.themes.length > 1 && fs.existsSync(this.themes.join(' '))) { - if (theme.includes('.css') && fs.existsSync(theme)) { - this.files.push(theme) - } else if (!theme.includes('.css') && fs.existsSync(path.resolve(__dirname + '/../assets/themes/' + theme + '.css'))) { - this.files.push(path.resolve(__dirname + '/../assets/themes/' + theme + '.css')) - } else { - console.error('(ERROR) Theme not found: "' + theme) + this.files.push(this.themes.join(' ')) + + } else { + + for (let theme of this.themes) { + + if (theme.includes('.css') && fs.existsSync(theme)) { + this.files.push(theme) + } else if (!theme.includes('.css') && fs.existsSync(path.resolve(__dirname + '/../assets/themes/' + theme + '.css'))) { + this.files.push(path.resolve(__dirname + '/../assets/themes/' + theme + '.css')) + } else { + console.error('(ERROR) Theme not found: "' + theme) + } } + } if (this.files.length) {