summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2023-10-11 17:19:08 +0200
committerVolpeon <git@volpeon.ink>2023-10-11 17:19:08 +0200
commitb7cd7b3b3dac3b0c0cf00a39af2cfb9c92314b5d (patch)
treebcd7561f8a91a4f28128d28c223799020375bdcd /scripts
parentAdd ghost (diff)
downloadiro-icons-b7cd7b3b3dac3b0c0cf00a39af2cfb9c92314b5d.tar.gz
iro-icons-b7cd7b3b3dac3b0c0cf00a39af2cfb9c92314b5d.tar.bz2
iro-icons-b7cd7b3b3dac3b0c0cf00a39af2cfb9c92314b5d.zip
Package updates; convert to ES module
Diffstat (limited to 'scripts')
-rw-r--r--scripts/create_sprite.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/scripts/create_sprite.js b/scripts/create_sprite.js
index 3bd4cf4..62aa6e0 100644
--- a/scripts/create_sprite.js
+++ b/scripts/create_sprite.js
@@ -1,6 +1,9 @@
1const SVGSpriter = require('svg-sprite'); 1import SVGSpriter from "svg-sprite";
2const fs = require('fs'); 2import { readFileSync, writeFileSync } from "fs";
3const path = require('path'); 3import { dirname, resolve } from "path";
4import { fileURLToPath } from "url";
5
6const __dirname = dirname(fileURLToPath(import.meta.url));
4 7
5const args = process.argv.slice(2); 8const args = process.argv.slice(2);
6const sprite = args.pop(); 9const sprite = args.pop();
@@ -10,16 +13,16 @@ const spriter = new SVGSpriter({
10 symbol: { 13 symbol: {
11 dest: "", 14 dest: "",
12 sprite, 15 sprite,
13 } 16 },
14 }, 17 },
15 shape: { 18 shape: {
16 transform: [] 19 transform: [],
17 } 20 },
18}); 21});
19 22
20for (const id of args) { 23for (const id of args) {
21 const file = path.resolve(__dirname, `../dist/${id}.svg`); 24 const file = resolve(__dirname, `../dist/${id}.svg`);
22 spriter.add(file, null, fs.readFileSync(file, { encoding: 'utf-8' })); 25 spriter.add(file, null, readFileSync(file, { encoding: "utf-8" }));
23} 26}
24 27
25spriter.compile((error, result) => { 28spriter.compile((error, result) => {
@@ -30,7 +33,10 @@ spriter.compile((error, result) => {
30 for (var mode in result) { 33 for (var mode in result) {
31 for (var resource in result[mode]) { 34 for (var resource in result[mode]) {
32 console.log(result[mode][resource].path); 35 console.log(result[mode][resource].path);
33 fs.writeFileSync(result[mode][resource].path, result[mode][resource].contents); 36 writeFileSync(
37 result[mode][resource].path,
38 result[mode][resource].contents
39 );
34 } 40 }
35 } 41 }
36}); 42});