From 09f9e9b2da779951ebd2f598afccaf887bdd2139 Mon Sep 17 00:00:00 2001 From: Grische Date: Fri, 26 Jul 2024 12:50:34 +0200 Subject: [PATCH] deprecate -big parameter --- .github/workflows/node-tests.yml | 9 --------- README.md | 7 ------- json-to-go.js | 11 ++--------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index 2bdd7dc..e5b2321 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -37,15 +37,6 @@ jobs: echo "got: '${got}'" [[ "${got}" == "${exp}" ]] - - name: Run json-to-go with -big using stdin - shell: bash - run: | - set -eEuo pipefail - got=$(node json-to-go.js -big < tests/double-nested-objects.json) - exp=$(cat tests/double-nested-objects.go) - echo "got: '${got}'" - [[ "${got}" == "${exp}" ]] - - name: Run json-to-go with a file shell: bash run: | diff --git a/README.md b/README.md index 67950a2..35e85c9 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,6 @@ Contributions are welcome! Open a pull request to fix a bug, or open an issue to cat sample.json | node json-to-go.js ``` -- Read large JSON file from stdin: - - ```sh - node json-to-go.js --big < sample.json - cat sample.json | node json-to-go.js --big - ``` - ### Credits JSON-to-Go is brought to you by Matt Holt ([mholt6](https://twitter.com/mholt6)). diff --git a/json-to-go.js b/json-to-go.js index fb31523..870ce0b 100644 --- a/json-to-go.js +++ b/json-to-go.js @@ -495,7 +495,6 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty if (typeof module != 'undefined') { if (!module.parent) { - let bigstdin = false let filename = null function jsonToGoWithErrorHandling(json) { @@ -518,7 +517,7 @@ if (typeof module != 'undefined') { const argument = val.replace(/-/g, '') if (argument === "big") - bigstdin = true + console.warn(`Warning: The argument '${argument}' has been deprecated and has no effect anymore`) else { console.error(`Unexpected argument ${val} received`) process.exit(1) @@ -532,7 +531,7 @@ if (typeof module != 'undefined') { return } - if (bigstdin) { + if (!filename) { bufs = [] process.stdin.on('data', function(buf) { bufs.push(buf) @@ -543,12 +542,6 @@ if (typeof module != 'undefined') { }) return } - - // read from stdin - process.stdin.on('data', function(buf) { - const json = buf.toString('utf8') - jsonToGoWithErrorHandling(json) - }) } else { module.exports = jsonToGo }