Skip to content

Commit

Permalink
deprecate -big parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
grische committed Jul 26, 2024
1 parent 93b78ea commit c162664
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/node-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
11 changes: 2 additions & 9 deletions json-to-go.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -532,7 +531,7 @@ if (typeof module != 'undefined') {
return
}

if (bigstdin) {
if (!filename) {
bufs = []
process.stdin.on('data', function(buf) {
bufs.push(buf)
Expand All @@ -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
}
Expand Down

0 comments on commit c162664

Please sign in to comment.