Skip to content

Commit

Permalink
End metro server gracefully when there are some edge errors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rafeca authored and facebook-github-bot committed Aug 30, 2018
1 parent b3ef345 commit b37c9c1
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions dependencies/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit b37c9c1

Please sign in to comment.