diff --git a/packages/bezier-icons/scripts/generate-icon-files.js b/packages/bezier-icons/scripts/generate-icon-files.js deleted file mode 100644 index 9fefad862c..0000000000 --- a/packages/bezier-icons/scripts/generate-icon-files.js +++ /dev/null @@ -1,8 +0,0 @@ -const path = require('path') - -const { generateIconFiles } = require('./utils/generateIconFilesFromJson') - -const bezierIconsDirectory = path.resolve(__dirname, '../icons') -const iconsJson = path.resolve(__dirname, '../icons.json') - -generateIconFiles(iconsJson, bezierIconsDirectory) diff --git a/packages/bezier-icons/scripts/utils/generateIconFilesFromJson.js b/packages/bezier-icons/scripts/utils/generateIconFilesFromJson.js deleted file mode 100644 index 014b392183..0000000000 --- a/packages/bezier-icons/scripts/utils/generateIconFilesFromJson.js +++ /dev/null @@ -1,33 +0,0 @@ -const fs = require('fs') -const path = require('path') - -const flushAndMakeIconsDirectory = (dir) => { - if (fs.existsSync(dir)) { - fs.rmSync(dir, { recursive: true, force: true }) - fs.mkdirSync(dir) - } -} - -const makeSvgFiles = - (dir) => - ([iconName, svgObject]) => { - const svgPath = path.resolve(dir, `${iconName}.svg`) - const { svg } = svgObject - - fs.writeFileSync(svgPath, svg, 'utf-8') - } - -const generateSVGFilesFromMap = (iconsJson, dir) => { - const svgByName = JSON.parse(fs.readFileSync(iconsJson, 'utf-8')) - - Object.entries(svgByName).forEach(makeSvgFiles(dir)) -} - -const generateIconFiles = (iconsJson, dir) => { - flushAndMakeIconsDirectory(dir) - generateSVGFilesFromMap(iconsJson, dir) -} - -module.exports = { - generateIconFiles, -} diff --git a/packages/bezier-icons/scripts/utils/generateIconFilesFromJson.test.js b/packages/bezier-icons/scripts/utils/generateIconFilesFromJson.test.js deleted file mode 100644 index db59eaf0b2..0000000000 --- a/packages/bezier-icons/scripts/utils/generateIconFilesFromJson.test.js +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable no-undef */ -const fs = require('fs') -const path = require('path') - -const { generateIconFiles } = require('./generateIconFilesFromJson') - -jest.mock('fs', () => ({ - existsSync: () => false, - rmSync: () => {}, - mkdirSync: () => {}, - readFileSync: (v) => v, - writeFileSync: jest.fn(), -})) - -const svgString = - '\\n\\n\\n' -const iconsJson = `{"send":{"svg":"${svgString}","id":"send"}}` -const iconSvg = JSON.parse(iconsJson).send.svg -const bezierIconsDirectory = path.resolve(__dirname, '..') - -describe('generate-icon-files script', () => { - test('writes file with icons.json given by figma-plugin', () => { - generateIconFiles(iconsJson, bezierIconsDirectory) - - expect(fs.writeFileSync).toHaveBeenCalledWith( - path.resolve(`${bezierIconsDirectory}/send.svg`), - iconSvg, - 'utf-8' - ) - }) -})