Update icons to work against Mustache
This commit is contained in:
parent
ab279faa7b
commit
c4b84db66d
7 changed files with 68 additions and 2101 deletions
|
@ -1,56 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
/*
|
||||
* > Build Icons
|
||||
*/
|
||||
|
||||
import Gulp from 'gulp';
|
||||
import runSequence from 'run-sequence';
|
||||
import Template from 'gulp-template';
|
||||
import Rename from 'gulp-rename';
|
||||
import FileList from 'gulp-filelist';
|
||||
import Include from 'gulp-include';
|
||||
import Data from 'gulp-data';
|
||||
import fs from 'fs';
|
||||
import gulp from 'gulp';
|
||||
import Mustache from 'mustache';
|
||||
import gutil from 'gulp-util';
|
||||
import Paths from '../paths';
|
||||
|
||||
import iconList from '../../iconlist.json';
|
||||
gulp.task('build:icons', cb => {
|
||||
const partials = fs.readdirSync(`${Paths.src}/icons/partials`);
|
||||
const partialData = {};
|
||||
const files = fs.readdirSync(`${Paths.src}/icons/svgs`);
|
||||
const icons = files.map(file => ({ name: file.split('.')[0], last: false }));
|
||||
icons[icons.length - 1].last = true;
|
||||
|
||||
|
||||
Gulp.task('build:icons', (cb) => {
|
||||
runSequence(
|
||||
'build:iconslist',
|
||||
'build:templateicons',
|
||||
(error) => {
|
||||
if (error) {
|
||||
console.log('\n[Build Icons]'.bold.magenta + ' There was an issue building icons:\n'.bold.red + error.message);
|
||||
} else {
|
||||
console.log('\n[Build Icons]'.bold.magenta + ' Finished successfully\n'.bold.green);
|
||||
}
|
||||
cb(error);
|
||||
}
|
||||
partials.forEach(partial => {
|
||||
partialData[partial.split('.')[0]] = fs.readFileSync(
|
||||
`${Paths.src}/icons/partials/${partial}`,
|
||||
'utf-8'
|
||||
);
|
||||
});
|
||||
|
||||
let contents = Mustache.render(
|
||||
fs.readFileSync(`${Paths.src}/icons/icons-theme.json`, 'utf-8'),
|
||||
{ icons },
|
||||
partialData
|
||||
);
|
||||
|
||||
Gulp.task('build:iconslist', () => {
|
||||
Gulp.src(`${Paths.src}/icons/svgs/*.svg`)
|
||||
.pipe(FileList('iconlist.json', {
|
||||
flatten: true,
|
||||
removeExtensions: true
|
||||
}))
|
||||
.pipe(Gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
Gulp.task('build:templateicons', () => {
|
||||
Gulp.src(`${Paths.src}/icons/icons-theme.json`)
|
||||
.pipe(Include())
|
||||
.on('error', console.log)
|
||||
.pipe(Data(() => ({ icons: iconList })))
|
||||
.pipe(Template())
|
||||
.pipe(Rename({
|
||||
basename: ".material-theme-icons",
|
||||
extname: ".tmp"
|
||||
}))
|
||||
.pipe(Gulp.dest('./'));
|
||||
try {
|
||||
contents = JSON.stringify(JSON.parse(contents), null, 2);
|
||||
} catch (err) {
|
||||
gutil.log(
|
||||
gutil.colors.red('There is an error with JSON generated for icons'),
|
||||
err
|
||||
);
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
const path = './.material-theme-icons.tmp';
|
||||
fs.writeFileSync(path, contents, 'utf-8');
|
||||
gutil.log('Generated', gutil.colors.green(path));
|
||||
|
||||
cb();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/*
|
||||
* > Build Themes
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import gulp from 'gulp';
|
||||
import gutil from 'gulp-util';
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
@ -69,13 +69,8 @@
|
|||
"gulp": "^3.9.1",
|
||||
"gulp-bump": "^2.7.0",
|
||||
"gulp-conventional-changelog": "^1.1.3",
|
||||
"gulp-data": "^1.2.1",
|
||||
"gulp-filelist": "^1.0.0",
|
||||
"gulp-if": "^2.0.2",
|
||||
"gulp-include": "^2.3.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-stats": "^0.0.4",
|
||||
"gulp-template": "^4.0.0",
|
||||
"gulp-util": "^3.0.8",
|
||||
"gulp-watch": "^4.3.8",
|
||||
"json-minify": "^1.0.0",
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
{
|
||||
//=include "partials/iconDefinitions.js"
|
||||
//=include "partials/fileExtensions.js"
|
||||
//=include "partials/fileNames.js"
|
||||
//=include "partials/fileFolders.js"
|
||||
//=include "partials/folderNames.js"
|
||||
//=include "partials/light.js"
|
||||
//=include "partials/languageIds.js"
|
||||
{{> iconDefinitions}}
|
||||
{{> fileNames}}
|
||||
{{> fileFolders}}
|
||||
{{> folderNames}}
|
||||
{{> light}}
|
||||
{{> languageIds}}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
"iconDefinitions": {<% for( var i = 0; i < icons.length; i++ ){ %>
|
||||
"iconDefinitions": {
|
||||
"_folder_dark": {
|
||||
"iconPath": "./icons/folder.svg"
|
||||
},
|
||||
|
@ -11,7 +11,9 @@
|
|||
"_file_dark": {
|
||||
"iconPath": "./icons/file.svg"
|
||||
},
|
||||
"_file_<%= icons[i] %>": {
|
||||
"iconPath": "./icons/<%= icons[i] %>.svg"
|
||||
}<% if( i !== (icons.length - 1)){ %>,<%} %><% } %>
|
||||
{{#icons}}
|
||||
"_file_{{name}}": {
|
||||
"iconPath": "./icons/{{name}}.svg"
|
||||
}{{^last}},{{/last}}
|
||||
{{/icons}}
|
||||
},
|
Loading…
Reference in a new issue