chore: should make variant icons generation automatic (based on defaults.json related property)

This commit is contained in:
octod 2017-11-06 09:32:52 +01:00
parent a4e05fa5d3
commit 80d47af2bd

View file

@ -1,6 +1,7 @@
import * as fs from 'fs'; import {getVariantIcons} from '../../extensions/helpers/fs';
import * as gulp from 'gulp'; import * as gulp from 'gulp';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs';
import { CHARSET } from "../../extensions/consts/files"; import { CHARSET } from "../../extensions/consts/files";
import { IPackageJSON } from "../../extensions/interfaces/ipackage.json"; import { IPackageJSON } from "../../extensions/interfaces/ipackage.json";
@ -8,6 +9,7 @@ import { IThemeIconsVariants } from "../interfaces/itheme-icons-variants";
import PATHS from '../../extensions/consts/paths' import PATHS from '../../extensions/consts/paths'
import { getDefaultValues } from "../../extensions/helpers/fs"; import { getDefaultValues } from "../../extensions/helpers/fs";
import { IDefaultsThemeVariantColours } from "../../extensions/interfaces/idefaults"; import { IDefaultsThemeVariantColours } from "../../extensions/interfaces/idefaults";
import { IThemeIconsItem } from '../interfaces/itheme-icons-item';
const PACKAGE_JSON: IPackageJSON = require(path.join(process.cwd(), './package.json')); const PACKAGE_JSON: IPackageJSON = require(path.join(process.cwd(), './package.json'));
@ -35,31 +37,18 @@ export default gulp.task('build:icons.variants', callback => {
let theme: IThemeIconsVariants = JSON.parse(JSON.stringify(basetheme)); let theme: IThemeIconsVariants = JSON.parse(JSON.stringify(basetheme));
let variant = variants[variantName]; let variant = variants[variantName];
theme.iconDefinitions._folder_dark.iconPath = theme.iconDefinitions._folder_dark.iconPath.replace('.svg', `${ variantName }.svg`); getVariantIcons().forEach(_iconName => {
theme.iconDefinitions._folder_dark_build.iconPath = theme.iconDefinitions._folder_dark_build.iconPath.replace('.svg', `${ variantName }.svg`); let basethemeIcon: IThemeIconsItem = (basetheme.iconDefinitions as any)[_iconName];
theme.iconDefinitions._folder_vscode.iconPath = theme.iconDefinitions._folder_vscode.iconPath.replace('.svg', `${ variantName }.svg`); let themeIcon: IThemeIconsItem = (theme.iconDefinitions as any)[_iconName];
theme.iconDefinitions._folder_gulp.iconPath = theme.iconDefinitions._folder_gulp.iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions._folder_node.iconPath = theme.iconDefinitions._folder_node.iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions._folder_images.iconPath = theme.iconDefinitions._folder_images.iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions._folder_js.iconPath = theme.iconDefinitions._folder_js.iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions._folder_src.iconPath = theme.iconDefinitions._folder_src.iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions._folder_assets.iconPath = theme.iconDefinitions._folder_assets.iconPath.replace('.svg', `${ variantName }.svg`);
// theme.iconDefinitions._file_folder.iconPath = theme.iconDefinitions._file_folder.iconPath.replace('.svg', `${ variantName }.svg`);
// theme.iconDefinitions["_file_folder_build"].iconPath = theme.iconDefinitions["_file_folder_build"].iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions._folder_light.iconPath = theme.iconDefinitions._folder_light.iconPath.replace('.svg', `${ variantName }.svg`);
theme.iconDefinitions["_folder_light_build"].iconPath = theme.iconDefinitions["_folder_light_build"].iconPath.replace('.svg', `${ variantName }.svg`);
writeIconVariant(basetheme.iconDefinitions._folder_dark.iconPath, theme.iconDefinitions._folder_dark.iconPath, variant); if (themeIcon !== undefined) {
writeIconVariant(basetheme.iconDefinitions._folder_dark_build.iconPath, theme.iconDefinitions._folder_dark_build.iconPath, variant); themeIcon.iconPath = themeIcon.iconPath.replace('.svg', `${ variantName }.svg`);
writeIconVariant(basetheme.iconDefinitions._folder_light.iconPath, theme.iconDefinitions._folder_light.iconPath, variant); }
writeIconVariant(basetheme.iconDefinitions._folder_vscode.iconPath, theme.iconDefinitions._folder_vscode.iconPath, variant);
writeIconVariant(basetheme.iconDefinitions._folder_gulp.iconPath, theme.iconDefinitions._folder_gulp.iconPath, variant); if (basethemeIcon !== undefined && themeIcon !== undefined) {
writeIconVariant(basetheme.iconDefinitions._folder_node.iconPath, theme.iconDefinitions._folder_node.iconPath, variant); writeIconVariant(basethemeIcon.iconPath, themeIcon.iconPath, variant);
writeIconVariant(basetheme.iconDefinitions._folder_images.iconPath, theme.iconDefinitions._folder_images.iconPath, variant); }
writeIconVariant(basetheme.iconDefinitions._folder_js.iconPath, theme.iconDefinitions._folder_js.iconPath, variant); });
writeIconVariant(basetheme.iconDefinitions._folder_src.iconPath, theme.iconDefinitions._folder_src.iconPath, variant);
writeIconVariant(basetheme.iconDefinitions._folder_assets.iconPath, theme.iconDefinitions._folder_assets.iconPath, variant);
writeIconVariant(basetheme.iconDefinitions["_folder_light_build"].iconPath, theme.iconDefinitions["_folder_light_build"].iconPath, variant);
}); });
}); });