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

identify: add missing await

This commit is contained in:
Starbeamrainbowlabs 2020-07-03 16:09:19 +01:00
parent 47c86c85e0
commit d5ebdb632d
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 9 additions and 31 deletions

View file

@ -3,11 +3,15 @@ This is the master changelog for [`terrain50-cli`](https://npmjs.org/packages/te
Release template text: Release template text:
Install or update from npm: -----
```bash Install or update from npm:
npm install --save terrain50-cli
``` ```bash
npm install --save terrain50-cli
```
-----
## Unreleased ## Unreleased

View file

@ -17,13 +17,11 @@ function summarise_obj(obj) {
} }
export default async function(settings) { export default async function(settings) {
let iterator = null; let iterator = null;
switch(settings.cli.mode) { switch(settings.cli.mode) {
case "single": case "single":
let obj = Terrain50.Parse( let obj = Terrain50.Parse(
fs.promises.readFile(settings.cli.input == "-" ? 0 : settings.cli.input, "utf-8") await fs.promises.readFile(settings.cli.input == "-" ? 0 : settings.cli.input, "utf-8")
); );
summarise_obj(obj); summarise_obj(obj);
break; break;
@ -41,30 +39,6 @@ export default async function(settings) {
i++; i++;
} }
} }
switch(settings.cli.mode) {
case "validate":
// Read stdin into a string - ref https://stackoverflow.com/a/56012724/1460422
let source = fs.readFileSync(0, 'utf-8');
let errors = Terrain50.Validate(source);
display_errors(errors);
break;
case "stream":
let i = 0;
for await (let next of Terrain50.ParseStream(process.stdin)) {
console.log(`>>> Item ${i} <<<`);
display_errors(next.validate());
i++;
}
break;
default:
console.error(`${a.fred}${a.hicol}Error: Mode '${settings.cli.mode}' was not recognised. Possible modes: validate (the default), stream.${a.reset}`);
process.exit(1);
}
} }
/** /**