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