Skip to content

Commit

Permalink
fix: add cleanning command
Browse files Browse the repository at this point in the history
=> run clean when push /
  • Loading branch information
Mara-Li committed May 24, 2022
1 parent bc15103 commit a5a0c87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions mkdocsPublisher/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class MkdocsPublication extends Plugin {
this.settings
);
new Notice(`Starting cleaning ${this.settings.githubRepo} `)
publish.deleteFromGithub();
publish.deleteFromGithub(false);
} catch (e) {
console.error(e);
}
Expand All @@ -169,7 +169,7 @@ export default class MkdocsPublication extends Plugin {
metadataCache,
this.settings
);
const sharedFiles = await publish.getSharedFiles();
const sharedFiles = publish.getSharedFiles();
const statusBar = new ShareStatusBar(
statusBarItems,
sharedFiles.length
Expand Down Expand Up @@ -206,6 +206,7 @@ export default class MkdocsPublication extends Plugin {
statusBar.finish(8000);
const noticeValue = `${publishedFiles.length - errorCount} notes`
await noticeMessage(publish, noticeValue, this.settings)
await publish.deleteFromGithub(true);
}
} catch (e) {
// statusBarItems.remove();
Expand Down
10 changes: 7 additions & 3 deletions mkdocsPublisher/utils/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default class MkdocsPublish {
}
if (one_file) {
await this.uploadFolder();
await this.deleteFromGithub(true);
}
return true;
} catch (e) {
Expand Down Expand Up @@ -253,7 +254,7 @@ export default class MkdocsPublish {
return sharedFilesInRepo;
}

async deleteFromGithub() {
async deleteFromGithub(silent = false) {
const octokit = new Octokit({
auth: this.settings.GhToken,
});
Expand All @@ -274,8 +275,9 @@ export default class MkdocsPublish {
) {
errorMsg =
"You need to configure a root folder in the settings to use this command.";
} if (!silent) {
new Notice("Error : " + errorMsg);
}
new Notice("Error : " + errorMsg);
}
return false;
}
Expand Down Expand Up @@ -314,7 +316,9 @@ export default class MkdocsPublish {
if (deletedFailed > 0) {
failedMsg = `Failed to delete ${deletedFailed} files.`
}
new Notice(successMsg + failedMsg)
if (!silent) {
new Notice(successMsg + failedMsg)
}
return true;
}

Expand Down

0 comments on commit a5a0c87

Please sign in to comment.