diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/acorn/bin | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/acorn/bin')
-rwxr-xr-x | node_modules/acorn/bin/acorn | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/node_modules/acorn/bin/acorn b/node_modules/acorn/bin/acorn index 41b786f42..257195780 100755 --- a/node_modules/acorn/bin/acorn +++ b/node_modules/acorn/bin/acorn @@ -10,60 +10,60 @@ var forceFile; var silent = false; var compact = false; var tokenize = false; -var options = {} +var options = {}; function help(status) { - var print = (status == 0) ? console.log : console.error - print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]") - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]") - process.exit(status) + var print = (status == 0) ? console.log : console.error; + print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|...|--ecma2015|--ecma2016|...]"); + print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]"); + process.exit(status); } for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i] - if ((arg == "-" || arg[0] != "-") && !infile) infile = arg - 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 == "--silent") silent = true - else if (arg == "--compact") compact = true - else if (arg == "--help") help(0) - else if (arg == "--tokenize") tokenize = true - else if (arg == "--module") options.sourceType = "module" + var arg = process.argv[i]; + if ((arg == "-" || arg[0] != "-") && !infile) { infile = arg; } + 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 == "--silent") { silent = true; } + else if (arg == "--compact") { compact = true; } + else if (arg == "--help") { help(0); } + else if (arg == "--tokenize") { tokenize = true; } + else if (arg == "--module") { options.sourceType = "module"; } else { - var match = arg.match(/^--ecma(\d+)$/) + var match = arg.match(/^--ecma(\d+)$/); if (match) - options.ecmaVersion = +match[1] + { options.ecmaVersion = +match[1]; } else - help(1) + { help(1); } } } function run(code) { - var result + var result; try { if (!tokenize) { - result = acorn.parse(code, options) + result = acorn.parse(code, options); } else { - result = [] - var tokenizer = acorn.tokenizer(code, options), token + result = []; + var tokenizer$$1 = acorn.tokenizer(code, options), token; do { - token = tokenizer.getToken() - result.push(token) + token = tokenizer$$1.getToken(); + result.push(token); } while (token.type != acorn.tokTypes.eof) } } catch (e) { - console.error(e.message) - process.exit(1) + console.error(e.message); + process.exit(1); } - if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2)) + if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); } } if (forceFile || infile && infile != "-") { - run(fs.readFileSync(infile, "utf8")) + run(fs.readFileSync(infile, "utf8")); } else { - var code = "" - process.stdin.resume() - process.stdin.on("data", function (chunk) { return code += chunk; }) - process.stdin.on("end", function () { return run(code); }) -}
\ No newline at end of file + var code = ""; + process.stdin.resume(); + process.stdin.on("data", function (chunk) { return code += chunk; }); + process.stdin.on("end", function () { return run(code); }); +} |