forked from channel-io/bezier-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bezier-icons): fix to javascript because of typescript file load…
… fail
- Loading branch information
1 parent
06330f9
commit 5709daa
Showing
8 changed files
with
53 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/bezier-icons/scripts/utils/generateIconFilesFromJson.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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, | ||
} |
8 changes: 4 additions & 4 deletions
8
...s/utils/generateIconFilesFromJson.test.ts → ...s/utils/generateIconFilesFromJson.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
packages/bezier-icons/scripts/utils/generateIconFilesFromJson.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ns/scripts/utils/getPrDescription.test.ts → ...ns/scripts/utils/getPrDescription.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters