From b7cd7b3b3dac3b0c0cf00a39af2cfb9c92314b5d Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 11 Oct 2023 17:19:08 +0200 Subject: Package updates; convert to ES module --- scripts/create_sprite.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'scripts') 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 @@ -const SVGSpriter = require('svg-sprite'); -const fs = require('fs'); -const path = require('path'); +import SVGSpriter from "svg-sprite"; +import { readFileSync, writeFileSync } from "fs"; +import { dirname, resolve } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); const args = process.argv.slice(2); const sprite = args.pop(); @@ -10,16 +13,16 @@ const spriter = new SVGSpriter({ symbol: { dest: "", sprite, - } + }, }, shape: { - transform: [] - } + transform: [], + }, }); for (const id of args) { - const file = path.resolve(__dirname, `../dist/${id}.svg`); - spriter.add(file, null, fs.readFileSync(file, { encoding: 'utf-8' })); + const file = resolve(__dirname, `../dist/${id}.svg`); + spriter.add(file, null, readFileSync(file, { encoding: "utf-8" })); } spriter.compile((error, result) => { @@ -30,7 +33,10 @@ spriter.compile((error, result) => { for (var mode in result) { for (var resource in result[mode]) { console.log(result[mode][resource].path); - fs.writeFileSync(result[mode][resource].path, result[mode][resource].contents); + writeFileSync( + result[mode][resource].path, + result[mode][resource].contents + ); } } }); -- cgit v1.2.3-70-g09d2