cli/launcher: add file browser button for the theme option and fix parsing path containing spaces if only one theme is set

This commit is contained in:
bordun 2021-02-17 13:51:02 +01:00
parent 44b7729117
commit 2ccb55c08f
3 changed files with 19 additions and 8 deletions

View file

@ -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)

View file

@ -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(/^[^=]*=[^=]*$/)) ?

View file

@ -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) {