Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > FileSystem > ensureEmptyFolder

FileSystem.ensureEmptyFolder() method

Deletes the content of a folder, but not the folder itself. Also ensures the folder exists. Behind the scenes it uses fs-extra.emptyDirSync().

Signature:

static ensureEmptyFolder(folderPath: string): void;

Parameters

ParameterTypeDescription
folderPathstringThe absolute or relative path to the folder which should have its contents deleted.

Returns:

void

Remarks

This is a workaround for a common race condition, where the virus scanner holds a lock on the folder for a brief period after it was deleted, causing EBUSY errors for any code that tries to recreate the folder.