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
|
* > Build Icons
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Gulp from 'gulp';
|
import fs from 'fs';
|
||||||
import runSequence from 'run-sequence';
|
import gulp from 'gulp';
|
||||||
import Template from 'gulp-template';
|
import Mustache from 'mustache';
|
||||||
import Rename from 'gulp-rename';
|
import gutil from 'gulp-util';
|
||||||
import FileList from 'gulp-filelist';
|
|
||||||
import Include from 'gulp-include';
|
|
||||||
import Data from 'gulp-data';
|
|
||||||
import Paths from '../paths';
|
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;
|
||||||
|
|
||||||
|
partials.forEach(partial => {
|
||||||
Gulp.task('build:icons', (cb) => {
|
partialData[partial.split('.')[0]] = fs.readFileSync(
|
||||||
runSequence(
|
`${Paths.src}/icons/partials/${partial}`,
|
||||||
'build:iconslist',
|
'utf-8'
|
||||||
'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);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let contents = Mustache.render(
|
||||||
Gulp.task('build:iconslist', () => {
|
fs.readFileSync(`${Paths.src}/icons/icons-theme.json`, 'utf-8'),
|
||||||
Gulp.src(`${Paths.src}/icons/svgs/*.svg`)
|
{ icons },
|
||||||
.pipe(FileList('iconlist.json', {
|
partialData
|
||||||
flatten: true,
|
);
|
||||||
removeExtensions: true
|
|
||||||
}))
|
try {
|
||||||
.pipe(Gulp.dest('./'));
|
contents = JSON.stringify(JSON.parse(contents), null, 2);
|
||||||
});
|
} catch (err) {
|
||||||
|
gutil.log(
|
||||||
|
gutil.colors.red('There is an error with JSON generated for icons'),
|
||||||
Gulp.task('build:templateicons', () => {
|
err
|
||||||
Gulp.src(`${Paths.src}/icons/icons-theme.json`)
|
);
|
||||||
.pipe(Include())
|
cb(err);
|
||||||
.on('error', console.log)
|
return;
|
||||||
.pipe(Data(() => ({ icons: iconList })))
|
}
|
||||||
.pipe(Template())
|
|
||||||
.pipe(Rename({
|
const path = './.material-theme-icons.tmp';
|
||||||
basename: ".material-theme-icons",
|
fs.writeFileSync(path, contents, 'utf-8');
|
||||||
extname: ".tmp"
|
gutil.log('Generated', gutil.colors.green(path));
|
||||||
}))
|
|
||||||
.pipe(Gulp.dest('./'));
|
cb();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
/*
|
||||||
|
* > Build Themes
|
||||||
|
*/
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
import gutil from 'gulp-util';
|
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": "^3.9.1",
|
||||||
"gulp-bump": "^2.7.0",
|
"gulp-bump": "^2.7.0",
|
||||||
"gulp-conventional-changelog": "^1.1.3",
|
"gulp-conventional-changelog": "^1.1.3",
|
||||||
"gulp-data": "^1.2.1",
|
|
||||||
"gulp-filelist": "^1.0.0",
|
|
||||||
"gulp-if": "^2.0.2",
|
"gulp-if": "^2.0.2",
|
||||||
"gulp-include": "^2.3.1",
|
|
||||||
"gulp-rename": "^1.2.2",
|
|
||||||
"gulp-stats": "^0.0.4",
|
"gulp-stats": "^0.0.4",
|
||||||
"gulp-template": "^4.0.0",
|
|
||||||
"gulp-util": "^3.0.8",
|
"gulp-util": "^3.0.8",
|
||||||
"gulp-watch": "^4.3.8",
|
"gulp-watch": "^4.3.8",
|
||||||
"json-minify": "^1.0.0",
|
"json-minify": "^1.0.0",
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
{
|
{
|
||||||
//=include "partials/iconDefinitions.js"
|
{{> iconDefinitions}}
|
||||||
//=include "partials/fileExtensions.js"
|
{{> fileNames}}
|
||||||
//=include "partials/fileNames.js"
|
{{> fileFolders}}
|
||||||
//=include "partials/fileFolders.js"
|
{{> folderNames}}
|
||||||
//=include "partials/folderNames.js"
|
{{> light}}
|
||||||
//=include "partials/light.js"
|
{{> languageIds}}
|
||||||
//=include "partials/languageIds.js"
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
"iconDefinitions": {<% for( var i = 0; i < icons.length; i++ ){ %>
|
"iconDefinitions": {
|
||||||
"_folder_dark": {
|
"_folder_dark": {
|
||||||
"iconPath": "./icons/folder.svg"
|
"iconPath": "./icons/folder.svg"
|
||||||
},
|
},
|
||||||
|
@ -11,7 +11,9 @@
|
||||||
"_file_dark": {
|
"_file_dark": {
|
||||||
"iconPath": "./icons/file.svg"
|
"iconPath": "./icons/file.svg"
|
||||||
},
|
},
|
||||||
"_file_<%= icons[i] %>": {
|
{{#icons}}
|
||||||
"iconPath": "./icons/<%= icons[i] %>.svg"
|
"_file_{{name}}": {
|
||||||
}<% if( i !== (icons.length - 1)){ %>,<%} %><% } %>
|
"iconPath": "./icons/{{name}}.svg"
|
||||||
|
}{{^last}},{{/last}}
|
||||||
|
{{/icons}}
|
||||||
},
|
},
|
Loading…
Reference in a new issue