Skip to content

Commit

Permalink
fix(web/script): asset generation
Browse files Browse the repository at this point in the history
  • Loading branch information
GervinFung committed Sep 23, 2024
1 parent f78f02f commit d015fe5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 8 additions & 9 deletions apps/web/script/assets/countries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from 'fs';

import data from '@periotable/data';
import axios from 'axios';
import { parse, string } from 'valibot';

import constants from '../../src/web/constant';

Expand All @@ -23,15 +22,15 @@ const element = () => {
responseType: 'arraybuffer',
})
.then(({ data }) => {
fs.writeFile(
`${path}/${country.svg}`,
parse(string(), data),
(error) => {
if (error) {
throw error;
}
if (!Buffer.isBuffer(data)) {
throw new Error('Data is not a buffer');
}

fs.writeFile(`${path}/${country.svg}`, data, (error) => {
if (error) {
throw error;
}
);
});
});
});
};
Expand Down
7 changes: 5 additions & 2 deletions apps/web/script/assets/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import fs from 'fs';
import data from '@periotable/data';
import { isNotUndefined } from '@poolofdeath20/util';
import axios from 'axios';
import { parse, string } from 'valibot';

import constants from '../../src/web/constant';
import { obtainNameFromUrl } from '../../src/web/util/asset';
Expand Down Expand Up @@ -59,7 +58,11 @@ const element = () => {
responseType: 'arraybuffer',
})
.then(({ data }) => {
fs.writeFile(props.name, parse(string(), data), (error) => {
if (!Buffer.isBuffer(data)) {
throw new Error('Data is not a buffer');
}

fs.writeFile(props.name, data, (error) => {
if (error) {
throw error;
}
Expand Down

0 comments on commit d015fe5

Please sign in to comment.