0.1.1 • Published 4 years ago
rm-diff-consoles v0.1.1
Removes all console.log statements from all staged files in a git repository.
Helpful for removing console.log automatically from changed files so it does not end up in production, while not accidentally removing console.log from other files in the project.
Works best when you use console.log solely for debugging, and console.info for printing information to the console as part of production behavior.
Usage
npx rm-diff-consolesTada! All your console.log statements have been removed.
Detailed Usage
- Add some
console.logstatements to one or more files in a git repository. - Stage changes:
git add -A - Run
npx rm-diff-consolesfrom the project's root directory. - The files are overwritten and the changes are left unstaged.
Use your git fu to verify the changes:
- Run
git diffto see the changes. - Run
git checkout .to restore the staged files. - Run
git add -Aandgit commit -m MESSAGEto commit all changes together. - Run
git MESSAGEto commit the original files and thengit add -Aandgit commit -m "remove console.log"to separate into two commits.
Example
Before:
const toTitleCase = (s: string) => s.split(' ').map(word => {
const first = word[0].toUpperCase()
const rest = word.slice(1).toLowerCase()).join(' ')
console.log(first) // just for debugging!!!
console.log(rest) // just for debugging!!!
return first + rest
}
export default toTitleCaseAfter:
const toTitleCase = (s: string) => s.split(' ').map(word => {
const first = word[0].toUpperCase()
const rest = word.slice(1).toLowerCase()).join(' ')
return first + rest
}
export default toTitleCase