-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78e7cdd
commit 4cf6942
Showing
5 changed files
with
37 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
import { IconsInlineDistDirectory, IconsOptimizedDirectory } from "./constants.ts"; | ||
|
||
// | ||
const optimizedIconsPath = IconsOptimizedDirectory; | ||
|
||
console.log("⚙️ Generating inline icons...\n"); | ||
|
||
const files = fs.readdirSync(optimizedIconsPath, { recursive: true, withFileTypes: true }); | ||
const svgFiles = files.filter(file => file.isFile() && file.name.endsWith(".svg")); | ||
|
||
// Clear directory (It also removes the directory itself) | ||
fs.rmSync(IconsInlineDistDirectory, { recursive: true, force: true }); | ||
fs.mkdirSync(IconsInlineDistDirectory, { recursive: true }); | ||
|
||
svgFiles.forEach(file => { | ||
const contents = fs.readFileSync(path.resolve(file.path, file.name), "utf8"); | ||
// TODO: fix the /, there is probably a method to join those paths | ||
fs.writeFileSync(`${IconsInlineDistDirectory}/${file.name.replace(".svg", ".js")}`, `export default \`${contents}\``); | ||
fs.writeFileSync(`${IconsInlineDistDirectory}/${file.name.replace(".svg", ".d.ts")}`, "declare const _default: string; export default _default;"); | ||
}); | ||
|
||
console.log("✨ The inline icons have been generated!\n"); |
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