Making destroyVault recursive, switching away from await/async when it's not necessary.

This commit is contained in:
Michael J. Pedersen 2023-02-13 10:32:55 -05:00
parent fc52e45cc2
commit 233df7952d

View file

@ -1,4 +1,4 @@
import {Plugin} from 'obsidian';
import {Plugin, TFolder} from 'obsidian';
import {newLoremNote} from "./loremnotes";
import {TestingVaultModal} from "./vault";
@ -9,11 +9,20 @@ import {TestingVaultModal} from "./vault";
which might be interesting for linguistic-related plugins
*/
function destroyVault(root: TFolder) {
for (let child of root.children) {
if (child instanceof TFolder) {
destroyVault(child);
this.app.vault.delete(child, true);
} else {
this.app.vault.delete(child, true);
}
}
}
export default class TestingVaultPlugin extends Plugin {
async deleteVaultContents() {
this.app.vault.getFiles().map(async (fname) => {
await this.app.vault.delete(fname, true)
});
deleteVaultContents() {
destroyVault(this.app.vault.getRoot());
}
async onload() {