vsc-material-theme/extensions/material.theme.config.ts
Mattia Astorino 9907cc8c67
Develop (#185)
* chore: Update meta and readme

* chore. Update README

* Refactor/linting - tslint-xo (#178)

* refactor(deps): added tslint, cleanup, and activationEvents modified

* refactor(lint): linting...

* refactor(changelog): changelo method refactor (should be tested)

* refactor(theme-icons):  linting and small refactor

* refactor(accents-setter): linting and small refactor

* chore(travis): added travis file

* fix(Lighter): Fix folders icon association

* chore: Clean test files

* fix(Icons): Add icon to .spec.ts files

* chore: Update git icon

* Update issue templates (#184)
2018-05-07 16:23:17 +02:00

46 lines
1.6 KiB
TypeScript

import {
workspace as Workspace,
commands as Commands
} from 'vscode';
import {THEME_ACCENTS_SETTER} from './commands/accents-setter/index';
import {THEME_ICONS} from './commands/theme-icons/index';
import {shouldShowChangelog, showChangelog} from './helpers/changelog';
import {reloadWindow, getCurrentThemeID, setIconsID} from './helpers/vscode';
const isMaterialTheme = (currentTheme: string): boolean =>
currentTheme.includes('Material Theme');
export function activate() {
const config = Workspace.getConfiguration();
// Listen on set theme: when the theme is Material Theme, just adjust icon and accent.
Workspace.onDidChangeConfiguration(event => {
const isColorTheme = event.affectsConfiguration('workbench.colorTheme');
const currentTheme = getCurrentThemeID();
// tslint:disable-next-line:early-exit
if (isColorTheme && isMaterialTheme(currentTheme)) {
setIconsID('eq-material-theme-icons')
.then(() => THEME_ICONS().catch(error => console.trace(error)))
.then(() => reloadWindow());
}
});
// Delete old configuration, must remove with next major release
if (config.has('materialTheme.cache.workbench')) {
config.update('materialTheme.cache.workbench', undefined, true);
}
if (shouldShowChangelog()) {
showChangelog();
}
// Registering commands
Commands.registerCommand('materialTheme.setAccent', () => THEME_ACCENTS_SETTER());
Commands.registerCommand('materialTheme.fixIcons', () =>
THEME_ICONS()
.then(() => reloadWindow())
.catch(err => console.trace(err))
);
Commands.registerCommand('materialTheme.showChangelog', () => showChangelog());
}