Skip to content

Commit aec3b93

Browse files
authored
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 <julian.wyzykowski@me.com>
1 parent 83a6e6f commit aec3b93

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

acorn/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ options:
250250
- `--allow-hash-bang`: If the code starts with the characters #! (as
251251
in a shellscript), the first line will be treated as a comment.
252252

253+
- `--allow-await-outside-function`: Allows top-level `await` expressions.
254+
See the `allowAwaitOutsideFunction` option for more information.
255+
253256
- `--compact`: No whitespace is used in the AST output.
254257

255258
- `--silent`: Do not output the AST, just return the exit status.

acorn/src/bin/acorn.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const options = {}
88
function help(status) {
99
const print = (status === 0) ? console.log : console.error
1010
print("usage: " + basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]")
11-
print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]")
11+
print(" [--tokenize] [--locations] [---allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [infile]")
1212
process.exit(status)
1313
}
1414

@@ -18,6 +18,7 @@ for (let i = 2; i < process.argv.length; ++i) {
1818
else if (arg === "--" && !infile && i + 2 === process.argv.length) forceFile = infile = process.argv[++i]
1919
else if (arg === "--locations") options.locations = true
2020
else if (arg === "--allow-hash-bang") options.allowHashBang = true
21+
else if (arg === "--allow-await-outside-function") options.allowAwaitOutsideFunction = true
2122
else if (arg === "--silent") silent = true
2223
else if (arg === "--compact") compact = true
2324
else if (arg === "--help") help(0)

0 commit comments

Comments
 (0)