Skip to content

Instantly share code, notes, and snippets.

@beerose
Last active February 5, 2019 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beerose/2ea4af6f14c0a67c8018d1a7d54f5dc0 to your computer and use it in GitHub Desktop.
Save beerose/2ea4af6f14c0a67c8018d1a7d54f5dc0 to your computer and use it in GitHub Desktop.
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