mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
Create output folder and converted folder if not existing
This commit is contained in:
parent
012547fe80
commit
0880dee377
@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import cairosvg
|
import cairosvg
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
Path("./converted/").mkdir(parents=True, exist_ok=True)
|
||||||
for file in os.listdir('./output'):
|
for file in os.listdir('./output'):
|
||||||
name = file.split('.svg')[0]
|
name = file.split('.svg')[0]
|
||||||
print('Converting ' + './output/' + name + '.svg' + ' -> ./converted/' + name + '.png')
|
print('Converting ' + './output/' + name + '.svg' + ' -> ./converted/' + name + '.png')
|
||||||
|
@ -166,6 +166,8 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
|
|||||||
document.querySelector("svg").outerHTML,
|
document.querySelector("svg").outerHTML,
|
||||||
].join("");
|
].join("");
|
||||||
|
|
||||||
|
const dir = path.split('/').slice(0, -1).join('/');
|
||||||
|
await fs.mkdir(dir, { recursive: true });
|
||||||
console.log("Writing to `" + path + ".svg`...");
|
console.log("Writing to `" + path + ".svg`...");
|
||||||
await fs.writeFile(`${path}.svg`, bakedSvg);
|
await fs.writeFile(`${path}.svg`, bakedSvg);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user