1
0
Fork 0
mirror of https://github.com/sbrl/terrain50-cli.git synced 2024-11-21 06:43:01 +00:00

json: support --tolerant

This commit is contained in:
Starbeamrainbowlabs 2022-12-06 17:54:53 +00:00
parent 4c1c0fbb6a
commit 1d8b1b4016
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 6 additions and 1 deletions

View file

@ -14,6 +14,10 @@ npm install --save terrain50-cli
-----
## v1.11 (unreleased)
- `json`: Support `--tolerant`
## v1.10 (6th December 2022)
- Update dependencies, including `applause-cli` (now `--help` will work on a per-subcommand basis if you do `terrain50 <subcommand> --help`)
- Add `json` subcommand for serialising to JSON[(L)](https://jsonlines.org/)

View file

@ -8,11 +8,12 @@ import a from '../../Helpers/Ansi.mjs';
import l from '../../Helpers/Log.mjs';
import Terrain50 from 'terrain50';
import { write_safe, end_safe } from '../../Helpers/StreamHelpers.mjs';
import settings from '../../Bootstrap/settings.mjs';
async function process_filename(filepath, stream_out) {
const stream_in = fs.createReadStream(filepath);
let i = 0;
for await(const frame of Terrain50.ParseStream(stream_in)) {
for await(const frame of Terrain50.ParseStream(stream_in, settings.cli.tolerant ? /\s+/ : " ")) {
const obj = frame.to_json();
await write_safe(stream_out, JSON.stringify(obj) + "\n");
i++;