packager: introducing async/await

Summary:
allow-large-files

By using async/await the code is (1) less nested, (2) more compact and (3) more robust (no exceptions running away, and much less risks of forgetting to call the callback/resolve, or mistakenly calling it twice). I now tend to think we could switch to it for all the callsites that are not in a perf-critical path.

I switched from 'request' to 'node-fetch' because 'request' has an annoying callback with 2 arguments. So it's simpler to use an interface that's (1) already returning a Promise and (2) that is becoming standard.

This changeset was a way for me to start experiment with introducing async/await in packager codebase, and it looks pretty good so far.

Reviewed By: cpojer

Differential Revision: D4559167

fbshipit-source-id: 89a328c5766c2ba890e9d0e67a81a38dac6cfc73
This commit is contained in:
Jean Lauliac 2017-02-15 13:36:14 -08:00 committed by Facebook Github Bot
parent 96a7d25bdf
commit 0ea19a62d7
1 changed files with 1 additions and 0 deletions

View File

@ -26,6 +26,7 @@ function config(onlyList) {
'transform-flow-strip-types',
'syntax-trailing-function-commas',
'transform-object-rest-spread',
'transform-async-to-generator',
],
only: _only,
retainLines: true,