From aec3b93e619e907b079b38799f06b46495a787b2 Mon Sep 17 00:00:00 2001 From: Julian Wyzykowski Date: Tue, 26 Jan 2021 02:33:03 -0500 Subject: [PATCH] Add flag to cli to enable await outside function option FEATURE: Add `--allow-await-outside-function` flag to command-line interface. Co-authored-by: julianwyz --- acorn/README.md | 3 +++ acorn/src/bin/acorn.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/acorn/README.md b/acorn/README.md index 029086785..e73a1031c 100644 --- a/acorn/README.md +++ b/acorn/README.md @@ -250,6 +250,9 @@ options: - `--allow-hash-bang`: If the code starts with the characters #! (as in a shellscript), the first line will be treated as a comment. +- `--allow-await-outside-function`: Allows top-level `await` expressions. + See the `allowAwaitOutsideFunction` option for more information. + - `--compact`: No whitespace is used in the AST output. - `--silent`: Do not output the AST, just return the exit status. diff --git a/acorn/src/bin/acorn.js b/acorn/src/bin/acorn.js index 9a6712c87..6c6be8caa 100644 --- a/acorn/src/bin/acorn.js +++ b/acorn/src/bin/acorn.js @@ -8,7 +8,7 @@ const options = {} function help(status) { const print = (status === 0) ? console.log : console.error print("usage: " + basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]") - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]") + print(" [--tokenize] [--locations] [---allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [infile]") process.exit(status) } @@ -18,6 +18,7 @@ for (let i = 2; i < process.argv.length; ++i) { else if (arg === "--" && !infile && i + 2 === process.argv.length) forceFile = infile = process.argv[++i] else if (arg === "--locations") options.locations = true else if (arg === "--allow-hash-bang") options.allowHashBang = true + else if (arg === "--allow-await-outside-function") options.allowAwaitOutsideFunction = true else if (arg === "--silent") silent = true else if (arg === "--compact") compact = true else if (arg === "--help") help(0)