dont-care-log

teach git stage/diff how to ignore specific logging code

Usage no npm install needed!

<script type="module">
  import dontCareLog from 'https://cdn.skypack.dev/dont-care-log';
</script>

README

dont-care-log

Build Status NPM Version NPM Downloads Node.js LICENSE

Teach git stage/diff how to ignore specific logging code,

so your logging code will never be commit automatically,

of course also wont show dirty in git.

Example

Assuming that a new file in you project like:

import path from 'path'

const getFile = () => {
  const name = 'foo'
  const file = path.join(__dirname, name)
  console.log('TCL: getFile() -> name:', file)
  return file
}

and with installed dont-care-log, you will only see this output below on git status/add/diff commands

+ import path from 'path'
+ 
+ const getFile = () => {
+   const name = 'foo'
+   const file = path.join(__dirname, name)
+   return file
+ }

Amazing, there is no line of console.log('TCL: ...)

Install

npm i -D dont-care-log

and Turbo Console Log for VSCode

How it works

dont-care-log only teach git to ignore the specific format line which is prefixed with any spaces and console.log('TCL: (default format of Turbo Console Log).

Well, here defined a filter.clean pipe to drop the specific line (generated by Turbo-Console-Log),

and some preinstall hook to setup .gitconfig and .gitattributes.

More details of git add/staging workflow see: > git-scm staging

In simple terms, filter.clean for staging, filter.smudge for checkout

filter-clean

filter-smudge

Next

  • multiline for per log functions
  • configurable
  • static parse current line to find out all variables
  • log plugin of webstorm

License

MIT LICENSE