Skip to content

Commit acd8566

Browse files
authored
Fix: Make cleanTask synchronous (#48)
* Fix: Make cleanTask synchronous This is to prevent it removing files when you 'copyFiles' to the same path directly after. This happens when using 'updateWorldTask' 'cleanCollateralTask' also is synchronous * Change files
1 parent 03e732f commit acd8566

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix: Make cleanTask synchronous This is to prevent it removing files when you 'copyFiles' to the same path directly after. This happens when using 'updateWorldTask' 'cleanCollateralTask' also is synchronous",
4+
"packageName": "@minecraft/core-build-tasks",
5+
"email": "maescool@gmail.com",
6+
"dependentChangeType": "patch"
7+
}

tools/core-build-tasks/src/tasks/clean.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ export const DEFAULT_CLEAN_DIRECTORIES = ['temp', 'lib', 'dist'];
99
export function cleanTask(dirs: string[]) {
1010
return () => {
1111
for (const dir of dirs) {
12-
console.log(`Cleaning ${dir}`);
13-
rimraf(path.resolve(process.cwd(), dir), () => {
14-
// no-op on unable to clean
15-
});
12+
try {
13+
console.log(`Cleaning ${dir}`);
14+
rimraf.sync(path.resolve(process.cwd(), dir));
15+
} catch (_: unknown) {
16+
// File or directory did not exist, so we no-op
17+
}
1618
}
1719
};
1820
}

0 commit comments

Comments
 (0)