vsc-material-but-i-wont-sue.../src/helpers/settings.ts
Alessio Occhipinti 50c057184c Feat/remove icons (#310)
* feat(Icons removal): Removed all related icons commands and files

* chore: fix (remove) all gulp related imports and task for icons

* chore: removed extensions folder and switch all imports (+ small fixes)

* chore: re-added defaults.json on root

* feat(Icons removal): Added vsc-material-theme-icons dependency
2019-01-31 21:35:51 +01:00

55 lines
1.6 KiB
TypeScript

import * as vscode from 'vscode';
import {IDefaults} from './../interfaces/idefaults';
import {IThemeCustomSettings} from './../interfaces/itheme-custom-properties';
import {getPackageJSON} from './fs';
/**
* Gets saved accent
*/
export function getAccent(): string | undefined {
return getCustomSettings().accent;
}
/**
* Gets custom settings
*/
export function getCustomSettings(): IThemeCustomSettings {
return vscode.workspace.getConfiguration().get<IThemeCustomSettings>('materialTheme', {});
}
/**
* Get showReloadNotification
*/
export function isReloadNotificationEnable(): boolean {
return vscode.workspace.getConfiguration().get<boolean>('materialTheme.showReloadNotification');
}
/**
* Checks if a given string could be an accent
*/
export function isAccent(accentName: string, defaults: IDefaults): boolean {
return Boolean(Object.keys(defaults.accents).find(name => name === accentName));
}
/**
* Determines if the passing theme id is a material theme
*/
export function isMaterialTheme(themeName: string): boolean {
const packageJSON = getPackageJSON();
return Boolean(packageJSON.contributes.themes.find(contrib => contrib.label === themeName));
}
/**
* Sets a custom property in custom settings
*/
export function setCustomSetting(settingName: string, value: any): Thenable<string> {
return vscode.workspace.getConfiguration().update(`materialTheme.${settingName}`, value, true).then(() => settingName);
}
/**
* Updates accent name
*/
export function updateAccent(accentName: string): Thenable<string> {
return setCustomSetting('accent', accentName);
}