Skip to content

Commit

Permalink
Simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tbradsha committed Jun 13, 2024
1 parent a4c1666 commit dbf5a12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
6 changes: 2 additions & 4 deletions projects/js-packages/social-logos/tools/svg-optimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
6 changes: 2 additions & 4 deletions projects/js-packages/social-logos/tools/svg-to-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
8 changes: 3 additions & 5 deletions projects/js-packages/social-logos/tools/svg-to-react-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 = [`;
Expand Down
6 changes: 2 additions & 4 deletions projects/js-packages/social-logos/tools/svg-to-sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } );
Expand Down

0 comments on commit dbf5a12

Please sign in to comment.