Skip to content

Commit

Permalink
Add flag to cli to enable await outside function option
Browse files Browse the repository at this point in the history
FEATURE: Add `--allow-await-outside-function` flag to command-line interface.

Co-authored-by: julianwyz <julian.wyzykowski@me.com>
  • Loading branch information
julianwyz and julianwyz authored Jan 26, 2021
1 parent 83a6e6f commit aec3b93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions acorn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion acorn/src/bin/acorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
Expand Down

0 comments on commit aec3b93

Please sign in to comment.