From dbf5a12c9fa4acfa7d1f6444d6560f524311cbe8 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:30:35 -0600 Subject: [PATCH] Simplify logic --- projects/js-packages/social-logos/tools/svg-optimize.js | 6 ++---- projects/js-packages/social-logos/tools/svg-to-font.js | 6 ++---- .../js-packages/social-logos/tools/svg-to-react-data.js | 8 +++----- projects/js-packages/social-logos/tools/svg-to-sprite.js | 6 ++---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/projects/js-packages/social-logos/tools/svg-optimize.js b/projects/js-packages/social-logos/tools/svg-optimize.js index 55804b690e9fd..15a94a5125410 100755 --- a/projects/js-packages/social-logos/tools/svg-optimize.js +++ b/projects/js-packages/social-logos/tools/svg-optimize.js @@ -38,10 +38,8 @@ const svgo_config = { const rootDir = __dirname + '/..'; process.chdir( rootDir ); -// Make dir if it doesn't exist. -if ( ! fs.existsSync( destSvgDir ) ) { - fs.mkdirSync( destSvgDir, { recursive: true } ); -} +// Make destination dir as needed. +fs.mkdirSync( destSvgDir, { recursive: true } ); const srcFiles = glob.sync( srcSvgDir + '/*.svg' ).sort(); for ( const srcFile of srcFiles ) { diff --git a/projects/js-packages/social-logos/tools/svg-to-font.js b/projects/js-packages/social-logos/tools/svg-to-font.js index 079a34f146d86..8e6dee559bad0 100755 --- a/projects/js-packages/social-logos/tools/svg-to-font.js +++ b/projects/js-packages/social-logos/tools/svg-to-font.js @@ -90,10 +90,8 @@ ${ cssCodepoints }*/`; // console.log('Wrote CSS file.'); }; -// Make dir if it doesn't exist. -if ( ! fs.existsSync( destFontDir ) ) { - fs.mkdirSync( destFontDir, { recursive: true } ); -} +// Make destination dir as needed. +fs.mkdirSync( destFontDir, { recursive: true } ); const codepoints = require( path.resolve( codepointsFile ) ); let maxCodepoint = Math.max( ...Object.values( codepoints ) ); diff --git a/projects/js-packages/social-logos/tools/svg-to-react-data.js b/projects/js-packages/social-logos/tools/svg-to-react-data.js index a77e1a1bdc394..75c15f85ad683 100755 --- a/projects/js-packages/social-logos/tools/svg-to-react-data.js +++ b/projects/js-packages/social-logos/tools/svg-to-react-data.js @@ -15,7 +15,7 @@ const rootDir = __dirname + '/..'; process.chdir( rootDir ); /** - * Transforms kebab case names to camel case + * Transforms kebab case names to camel case. * @param {string} name - e.g.: foo-bar-baz * @returns {string} e.g.: fooBarBaz */ @@ -26,10 +26,8 @@ function kebabToCamelCase( name ) { } ); } -// Make dir if it doesn't exist. -if ( ! fs.existsSync( destReactDir ) ) { - fs.mkdirSync( destReactDir, { recursive: true } ); -} +// Make destination dir as needed. +fs.mkdirSync( destReactDir, { recursive: true } ); let socialLogoData = `/** This is a generated file. Do not edit. */ export const SocialLogoData = [`; diff --git a/projects/js-packages/social-logos/tools/svg-to-sprite.js b/projects/js-packages/social-logos/tools/svg-to-sprite.js index 0ec809ce00dfe..fb023bfc8b1ee 100755 --- a/projects/js-packages/social-logos/tools/svg-to-sprite.js +++ b/projects/js-packages/social-logos/tools/svg-to-sprite.js @@ -16,10 +16,8 @@ const svgstore = require( 'svgstore' ); const rootDir = __dirname + '/..'; process.chdir( rootDir ); -// Make dir if it doesn't exist. -if ( ! fs.existsSync( destSpriteDir ) ) { - fs.mkdirSync( destSpriteDir, { recursive: true } ); -} +// Make destination dir as needed. +fs.mkdirSync( destSpriteDir, { recursive: true } ); // Generate SVG. const sprites = svgstore( { inline: true } );