fix: localesのファイル変更イベントが取れないのを修正

This commit is contained in:
yukineko 2023-11-27 19:41:39 +09:00
parent 50ceb52e2a
commit e87b1a7155
No known key found for this signature in database
GPG key ID: E5BACB72109B7B90

View file

@ -91,21 +91,16 @@ async function build() {
await build();
if (process.argv.includes("--watch")) {
const watchers = [
fs.watch('./packages', { recursive: true }),
fs.watch('./locales'),
];
const watcher = fs.watch('./', { recursive: true });
while (true) {
const event = (await Promise.race(watchers.map(watcher => watcher.next())))?.value;
if (!event) continue;
const filename = event.filename?.replaceAll('\\', '/');
for await (const event of watcher) {
const filename = event.filename.replaceAll('\\', '/');
if (/^[a-z]+\/src/.test(filename)) {
if (/^packages\/[a-z]+\/src/.test(filename)) {
await build();
}
if (/[a-z]+-[A-Z]+\.yml/.test(filename)) {
if (/^locales\/[a-z]+-[A-Z]+\.yml/.test(filename)) {
locales = buildLocales();
await copyFrontendLocales()
}