End metro server gracefully when there are some edge errors

Summary: This diff fixes a couple of edge cases that caused Metro to keep the process running when there were some specific errors (specially around the `dependencies` command and the transformer path).

Reviewed By: jrwats

Differential Revision: D9551834

fbshipit-source-id: 959cefcec9e2687dff89c94a871ae74c50d2dd77
This commit is contained in:
Rafael Oleza 2018-08-30 03:22:17 -07:00 committed by Facebook Github Bot
parent f9e823fb5a
commit f661e0fb6e
1 changed files with 19 additions and 22 deletions

View File

@ -44,29 +44,26 @@ async function dependencies(argv, configPromise, args, packagerInstance) {
? fs.createWriteStream(args.output)
: process.stdout;
return Promise.resolve(
(packagerInstance
? packagerInstance.getOrderedDependencyPaths(options)
: Metro.getOrderedDependencyPaths(config, options)
).then(deps => {
deps.forEach(modulePath => {
// Temporary hack to disable listing dependencies not under this directory.
// Long term, we need either
// (a) JS code to not depend on anything outside this directory, or
// (b) Come up with a way to declare this dependency in Buck.
const isInsideProjectRoots =
config.watchFolders.filter(root => modulePath.startsWith(root))
.length > 0;
const deps = packagerInstance
? await packagerInstance.getOrderedDependencyPaths(options)
: await Metro.getOrderedDependencyPaths(config, options);
if (isInsideProjectRoots) {
outStream.write(modulePath + '\n');
}
});
return writeToFile
? denodeify(outStream.end).bind(outStream)()
: Promise.resolve();
}),
);
deps.forEach(modulePath => {
// Temporary hack to disable listing dependencies not under this directory.
// Long term, we need either
// (a) JS code to not depend on anything outside this directory, or
// (b) Come up with a way to declare this dependency in Buck.
const isInsideProjectRoots =
config.watchFolders.filter(root => modulePath.startsWith(root)).length >
0;
if (isInsideProjectRoots) {
outStream.write(modulePath + '\n');
}
});
return writeToFile
? denodeify(outStream.end).bind(outStream)()
: Promise.resolve();
}
module.exports = {