1
0
mirror of https://github.com/konpa/devicon.git synced 2025-08-05 22:27:28 +02:00

Optimize bot is now a part of the build script (#624)

Co-authored-by: Clemens Bastian <8781699+amacado@users.noreply.github.com>
This commit is contained in:
Thomas Bui
2021-05-27 07:24:59 -07:00
committed by GitHub
parent 1e01930573
commit 48ebd6a93c
2 changed files with 18 additions and 25 deletions

View File

@@ -160,35 +160,15 @@ function cleanUp() {
* This must be passed through the commandline arguments.
*/
function optimizeSvg() {
let svgPaths = getAddedModifiedSvg(yargs.argv.filesAddedJson,
yargs.argv.filesModifiedJson)
return gulp.src(svgPaths)
let svgGlob = JSON.parse(yargs.argv.svgFiles)
console.log("Optimizing these files: ", svgGlob)
return gulp.src(svgGlob)
.pipe(svgmin(configOptionCallback))
.pipe(gulp.dest(file => {
return file.base
}))
}
/**
* Get the svgs added and modified from the '/icons' folder only.
* @param {*} filesAddedJson - the files that were added in this commit.
* @param {*} filesModifiedJson - the files that were modified in this commit.
* @returns a list of the svg file paths that were added/modified in this pr as Path.
* It will only return icons in '/icons' path (see https://github.com/devicons/devicon/issues/505)
*/
function getAddedModifiedSvg(filesAddedJson, filesModifiedJson) {
const filesAdded = JSON.parse(filesAddedJson),
filesModified = JSON.parse(filesModifiedJson)
files = filesAdded.concat(filesModified)
return files.filter(filename => {
if (path.extname(filename) == ".svg"
&& path.dirname(filename).includes('icons/'))
return filename
})
}
/**
* Create a config option for each file.
* @param {Object} file - Gulp Vinyl instance of the file