mirror of
https://github.com/sbrl/terrain50-cli.git
synced 2024-11-26 07:33:00 +00:00
identify: add missing await
This commit is contained in:
parent
47c86c85e0
commit
d5ebdb632d
2 changed files with 9 additions and 31 deletions
|
@ -3,12 +3,16 @@ This is the master changelog for [`terrain50-cli`](https://npmjs.org/packages/te
|
||||||
|
|
||||||
Release template text:
|
Release template text:
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
Install or update from npm:
|
Install or update from npm:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install --save terrain50-cli
|
npm install --save terrain50-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
- Added new (untested!) `identify` subcommand
|
- Added new (untested!) `identify` subcommand
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue