From f498c46968cf8cb7a3659b7b2bb1b382c2551dd5 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Mon, 14 Sep 2020 11:17:00 -0700 Subject: [PATCH] Added extra artifact generation and logging function --- gulpfile.js | 13 ++++--------- upgradeDev.js | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a76455a3..c5082af7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,7 +34,9 @@ async function createDeviconMinCSS() { await fsPromise.writeFile(deviconMinPath, fileContent, "utf8"); return gulp.src(finalMinSCSSName) - .pipe(sass.sync({"outputStyle": "compressed"}).on('error', sass.logError)) + // to get a minify version, uncomment line 38 and comment line 39 + // .pipe(sass.sync({"outputStyle": "compressed"}).on('error', sass.logError)) + .pipe(sass.sync().on('error', sass.logError)) .pipe(gulp.dest('./')); } @@ -66,12 +68,6 @@ async function createCSSFiles() { * created. */ function createAliasSCSS(deviconJson) { - // let css = await fsPromise.readFile( - // path.join(__dirname, "devicon.css"), "utf8" - // ); - - // let statements = css.match(/\.devicon-(.*\s+){2,}?(?=})/g).map(str => - // createAliasesStatement(str, deviconJson)); let statements = deviconJson.map(createAliasStatement).join(" "); let sass = `@use "devicon";${statements}`; let sassPath = path.join(__dirname, aliasSCSSName); @@ -119,10 +115,9 @@ function createColorsCSS(deviconJson) { } = fontObj; if (fonts.length === 0 || typeof(color) !== "string") { - console.log(name); + console.log(`This object doesn't have a font or a color: ${name}`); return ""; } - // loop through the fonts and create css classes let cssClasses = fonts.map(font => `.devicon-${name}-${font}`); return `${cssClasses.join(",")}{color: ${color}}`; }).join(" "); diff --git a/upgradeDev.js b/upgradeDev.js index dcfbce01..67f2912a 100644 --- a/upgradeDev.js +++ b/upgradeDev.js @@ -14,12 +14,13 @@ function main() { let colorsMap = constructColorsMap(); // if you want to see what the maps are like - // fs.writeFileSync(path.join(__dirname, "contentMap.json"), - // JSON.stringify(contentMap), "utf8"); - // fs.writeFileSync(path.join(__dirname, "aliasMap.json"), - // JSON.stringify(aliasMap), "utf8"); - // fs.writeFileSync(path.join(__dirname, "colorsMap.json"), - // JSON.stringify(colorsMap), "utf8"); + // these maps are essential to create the final newDevicon.json + fs.writeFileSync(path.join(__dirname, "contentMap.json"), + JSON.stringify(contentMap), "utf8"); + fs.writeFileSync(path.join(__dirname, "aliasMap.json"), + JSON.stringify(aliasMap), "utf8"); + fs.writeFileSync(path.join(__dirname, "colorsMap.json"), + JSON.stringify(colorsMap), "utf8"); createNewDeviconJson(colorsMap, contentMap, aliasMap); } @@ -136,12 +137,12 @@ function createNewDeviconJson(colorsMap, contentMap, aliasMap) { // run check to ensure every object has the needed attribute // log all fonts that are missing a color or don't have an array - // let specialFont = newDeviconJson.filter(fontObj => { - // return !(typeof(fontObj["color"]) === "string" - // && Array.isArray(fontObj["aliases"])); - // }) + let specialFont = newDeviconJson.filter(fontObj => { + return !(typeof(fontObj["color"]) === "string" + && Array.isArray(fontObj["aliases"])); + }) - // console.log(specialFont); + console.log(specialFont); } /**