Skip to content

Commit

Permalink
add awaitWriteFinish to resourcepack watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAfroOfDoom committed Jan 24, 2024
1 parent 009d4cf commit 5cdd1d8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions package-scripts/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const worldPath = `${minecraftPath}/saves/${worldName}`;
const resourcePackBasePath = `${minecraftPath}/resourcepacks/${resourcePackName}`;
const regexDotFiles = /(^|[/\\])\../;

const awaitWriteFinish = {
stabilityThreshold: 200,
pollInterval: 100,
};

const watchDatapacks = async (showVerbose) => {
const log = (...args) => {
const prefix = chalk.bgBlue(chalk.bold('[datapacks]'));
Expand All @@ -60,10 +65,6 @@ const watchDatapacks = async (showVerbose) => {
await remove(`${worldPath}/datapacks`);
await copy('datapacks', `${worldPath}/datapacks`, { filter: copyFilter });

const awaitWriteFinish = {
stabilityThreshold: 200,
pollInterval: 100,
};
const watcher = watch('datapacks', {
awaitWriteFinish,
ignored,
Expand Down Expand Up @@ -117,7 +118,11 @@ const watchResourcepack = async (showVerbose) => {
await remove(resourcePackBasePath);
await copy('resourcepack', resourcePackBasePath, { filter: copyFilter });

const watcher = watch('resourcepack', { ignored, ignoreInitial: true });
const watcher = watch('resourcepack', {
awaitWriteFinish,
ignored,
ignoreInitial: true,
});

watcher.on('ready', async () => {
log('initialized');
Expand Down

0 comments on commit 5cdd1d8

Please sign in to comment.