From d5ebdb632dec722d708845d5b3585e95a3fd2d6e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 3 Jul 2020 16:09:19 +0100 Subject: [PATCH] identify: add missing await --- Changelog.md | 12 ++++++++---- src/Subcommands/identify/index.mjs | 28 +--------------------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/Changelog.md b/Changelog.md index 6b31a8c..fb68119 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,11 +3,15 @@ This is the master changelog for [`terrain50-cli`](https://npmjs.org/packages/te Release template text: - Install or update from npm: +----- - ```bash - npm install --save terrain50-cli - ``` +Install or update from npm: + +```bash +npm install --save terrain50-cli +``` + +----- ## Unreleased diff --git a/src/Subcommands/identify/index.mjs b/src/Subcommands/identify/index.mjs index 6c98a70..5071a4b 100644 --- a/src/Subcommands/identify/index.mjs +++ b/src/Subcommands/identify/index.mjs @@ -17,13 +17,11 @@ function summarise_obj(obj) { } export default async function(settings) { - - let iterator = null; switch(settings.cli.mode) { case "single": 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); break; @@ -41,30 +39,6 @@ export default async function(settings) { 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); - } } /**