vsc-material-theme/.gulp/tasks/icons-variants-json.ts
Alessio Occhipinti 82cfb4587b Small refactor + UX improvements [WIP] (#190)
* chore: small cleanup helper

* chore: adding interfaces for icon variants

* feat: You can now switch between Material Theme icons

* chore: helpers small fix

* chore(helpers): small fix helpers

* refactor: refactoring fixIcons command, ready for new prop autoFix

* refactor: accentsSetter command, ready for autoFix prop

* chore: added new exports file for all commands

* refactor: main theme file, ready for autoFix prop

* chore: added listener also when changing iconTheme

* feat: autoApplyIcons added as option and toggleApplyIcons as command

* chore: added check for autoApplyIcons flag. Removed listen icon change

* feat: Notification shows up when the window needs reload

* chore: Update CTA's

* chore: Make consistent indent guides and add support to editorIndentGuide.activeBackground

Close #188

* chore: fix check on CTA ok

* chore: split up configurationChange and changelog  (added to commands)

* chore: small change settings method

* feat: Now the theme will auto fix if needed on change icons theme
2018-05-18 13:47:22 +02:00

37 lines
1.3 KiB
TypeScript

import * as fs from 'fs';
import * as gulp from 'gulp';
import {resolve} from 'path';
import {IDefaultsThemeIconVariant} from './../../extensions/interfaces/idefaults';
import {getDefaultValues, getVariantIcons} from './../../extensions/helpers/fs';
import {PATHS} from '../../extensions/consts/paths';
import {CHARSET} from '../../extensions/consts/files';
/**
* For each ThemeIconVariant create a Material-Theme-Icons-{variant}.json
* depends on default Material-Theme-Icons.json
*/
export default gulp.task('build:icons.variants-json', callback => {
try {
const variants: IDefaultsThemeIconVariant = getDefaultValues().themeIconVariants;
const defaults = fs.readFileSync(resolve(`${PATHS.THEMES}/Material-Theme-Icons.json`), 'utf8');
Object.keys(variants).forEach(variantName => {
const jsonDefaults = JSON.parse(defaults);
getVariantIcons().forEach(iconname => {
const newIconPath = jsonDefaults.iconDefinitions[iconname].iconPath.replace('.svg', `${variantName}.svg`);
jsonDefaults.iconDefinitions[iconname].iconPath = newIconPath;
fs.writeFileSync(
`${PATHS.THEMES}/Material-Theme-Icons-${variantName}.json`,
JSON.stringify(jsonDefaults),
{encoding: CHARSET}
);
});
});
} catch (error) {
return callback(error);
}
callback();
});