handle Hyper plugin crashes (fixes #71)

This commit is contained in:
Eugene Pankov 2017-08-30 11:23:51 +02:00
parent 1b2236eb90
commit 4d2be9ec89

View File

@ -13,35 +13,39 @@ export class HyperColorSchemes extends TerminalColorSchemeProvider {
let themes: ITerminalColorScheme[] = [] let themes: ITerminalColorScheme[] = []
plugins.forEach(plugin => { plugins.forEach(plugin => {
let module = (global as any).require(path.join(pluginsPath, plugin)) try {
if (module.decorateConfig) { let module = (global as any).require(path.join(pluginsPath, plugin))
let config = module.decorateConfig({}) if (module.decorateConfig) {
if (config.colors) { let config = module.decorateConfig({})
themes.push({ if (config.colors) {
name: plugin, themes.push({
foreground: config.foregroundColor, name: plugin,
background: config.backgroundColor, foreground: config.foregroundColor,
cursor: config.cursorColor, background: config.backgroundColor,
colors: config.colors.black ? [ cursor: config.cursorColor,
config.colors.black, colors: config.colors.black ? [
config.colors.red, config.colors.black,
config.colors.green, config.colors.red,
config.colors.yellow, config.colors.green,
config.colors.blue, config.colors.yellow,
config.colors.magenta, config.colors.blue,
config.colors.cyan, config.colors.magenta,
config.colors.white, config.colors.cyan,
config.colors.lightBlack, config.colors.white,
config.colors.lightRed, config.colors.lightBlack,
config.colors.lightGreen, config.colors.lightRed,
config.colors.lightYellow, config.colors.lightGreen,
config.colors.lightBlue, config.colors.lightYellow,
config.colors.lightMagenta, config.colors.lightBlue,
config.colors.lightCyan, config.colors.lightMagenta,
config.colors.lightWhite, config.colors.lightCyan,
] : config.colors, config.colors.lightWhite,
}) ] : config.colors,
})
}
} }
} catch (err) {
console.debug('Skipping Hyper plugin', plugin, err)
} }
}) })