Here's an example of using the removeSync
function from the fs-extra
library in TypeScript:
index.ts265 chars11 lines
The removeSync
function deletes the file or directory at the specified path. It is synchronous, which means the code will block until the deletion is complete. If the deletion is successful, it will log a success message to the console. If an error occurs, it will log an error message to the console.
Note that the removeSync
function throws an error if the specified path does not exist, or if it points to a non-empty directory. If you want to delete a non-empty directory, you should use the asynchronous remove
function instead. You can use the await
keyword with remove
to wait for the deletion to complete before continuing with the rest of your code.
gistlibby LogSnag