fix: adopt fs api changes

This commit is contained in:
deepak1556 2021-11-18 00:25:43 +09:00
parent ef62374ef7
commit 0cb6aa508a
2 changed files with 9 additions and 4 deletions

View file

@ -44,7 +44,7 @@ async function rimraf(path: string, mode = RimRafMode.UNLINK): Promise<void> {
throw new Error('rimraf - will refuse to recursively delete root');
}
// delete: via rmDir
// delete: via rm
if (mode === RimRafMode.UNLINK) {
return rimrafUnlink(path);
}
@ -72,7 +72,9 @@ async function rimrafMove(path: string): Promise<void> {
}
async function rimrafUnlink(path: string): Promise<void> {
return Promises.rmdir(path, { recursive: true, maxRetries: 3 });
// Use rm instead of rmdir for
// https://github.com/nodejs/node/commit/9948036ee0
return promisify(fs.rm)(path, { recursive: true, force: true, maxRetries: 3 });
}
export function rimrafSync(path: string): void {
@ -80,7 +82,9 @@ export function rimrafSync(path: string): void {
throw new Error('rimraf - will refuse to recursively delete root');
}
fs.rmdirSync(path, { recursive: true });
// Use rmSync instead of rmdirSync for
// https://github.com/nodejs/node/commit/9948036ee0
fs.rmSync(path, { recursive: true, force: true });
}
//#endregion

View file

@ -280,7 +280,8 @@ flakySuite('PFS', function () {
const linkTarget = await Promises.readlink(targetLinkMD5JSFolderLinked);
assert.strictEqual(linkTarget, targetLinkMD5JSFolder);
await Promises.rmdir(targetLinkTestFolder, { recursive: true });
// Ref https://github.com/nodejs/node/commit/0ddd75bcd816a8e5f4e27411b8e913abb92c2ed5
await Promises.rm(targetLinkTestFolder);
}
// Copy with `preserveSymlinks: false` and verify result