0.6.5 • Published 1 year ago

git-grep-json v0.6.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

git-grep-json

It's a tool for git-grep. See https://git-grep-json.netlify.app/ also.

npm NPM npms.io (quality) Libraries.io dependency status for latest release Maintenance

installation

npm install git-grep-json

usage

  • grep with -n and -C

    git grep -n -C 2 -e "some" | npx grep2json
  • grep with -n and -A

    git grep -n -A 1 -e "some" | npx grep2json
  • grep with -n and -B

    git grep -n -B 1 -e "some" | npx grep2json
  • result

    [
      {
        "fileName": "test.js",
        "matchedLineNumber": 1,
        "codeLines": [
          "function someFunc(){",
          "  return 1;"
        ],
        "lineRange": {
          "start": 1,
          "end": 2
        }
      },
      {
        "fileName": "test.js",
        "matchedLineNumber": 6,
        "codeLines": [
          "function otherFunc(){",
          "  return \"awesome\";",
          "}"
        ],
        "lineRange": {
          "start": 5,
          "end": 7
        }
      }
    ]

configurations

grep2json.config.js in process currend directory can change the outout.

You can get grep2json.config.js with the below line

npx gren2json --init-config

configuration example

module.exports = {
  prepareStore: async () => await Promise.resolve({}),
  setupResult: async (block, structuredLine, store) => {
    return await Promise.resolve({
      fileName: structuredLine.fileName,
      matchedLineNumber: structuredLine.lineNumber,
      line: structuredLine.codeLine
    });
  }
};

prepareStore()

prepareStore() in grep2json.config.js will be executed once before setupResult().

prepareStore() should return a Promise that resolves as any object.

setupResult()

setupResult() in grep2json.config.js will be executed with each matched line.

setupResult() should return a Promise that resolves as any object.

setupResult() receives block, line, and store as the parameters.

0.6.5

1 year ago

0.6.4

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago