Last active
February 5, 2019 19:38
-
-
Save beerose/2ea4af6f14c0a67c8018d1a7d54f5dc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { purify } from 'profanity-util'; | |
import * as vscode from 'vscode'; | |
export const purifyLogs = () => { | |
const { | |
activeTextEditor: { document }, | |
} = vscode.window; | |
const workspaceEdit = new vscode.WorkspaceEdit(); | |
const logs = getConsoleLogs(document); | |
logs.forEach( | |
log => | |
log.badWords && | |
workspaceEdit.replace(document.uri, log.range, log.purified) | |
); | |
const badWordsCount = logs.reduce( | |
(prev, next) => prev + next.badWords, | |
0 | |
); | |
vscode.workspace.applyEdit(workspaceEdit).then(() => { | |
badWordsCount | |
? vscode.window.showInformationMessage( | |
`Number of bad words that were censored: ${badWordsCount} π€¬π€¬π€¬π€¬` | |
) | |
: vscode.window.showInformationMessage( | |
'No bad words! ππππ' | |
); | |
document.save(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment