Skip to content

Commit 7156c86

Browse files
rafecakelset
authored andcommitted
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
1 parent 9f83fcc commit 7156c86

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

local-cli/dependencies/dependencies.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,26 @@ async function dependencies(argv, configPromise, args, packagerInstance) {
4444
? fs.createWriteStream(args.output)
4545
: process.stdout;
4646

47-
return Promise.resolve(
48-
(packagerInstance
49-
? packagerInstance.getOrderedDependencyPaths(options)
50-
: Metro.getOrderedDependencyPaths(config, options)
51-
).then(deps => {
52-
deps.forEach(modulePath => {
53-
// Temporary hack to disable listing dependencies not under this directory.
54-
// Long term, we need either
55-
// (a) JS code to not depend on anything outside this directory, or
56-
// (b) Come up with a way to declare this dependency in Buck.
57-
const isInsideProjectRoots =
58-
config.watchFolders.filter(root => modulePath.startsWith(root))
59-
.length > 0;
47+
const deps = packagerInstance
48+
? await packagerInstance.getOrderedDependencyPaths(options)
49+
: await Metro.getOrderedDependencyPaths(config, options);
6050

61-
if (isInsideProjectRoots) {
62-
outStream.write(modulePath + '\n');
63-
}
64-
});
65-
return writeToFile
66-
? denodeify(outStream.end).bind(outStream)()
67-
: Promise.resolve();
68-
}),
69-
);
51+
deps.forEach(modulePath => {
52+
// Temporary hack to disable listing dependencies not under this directory.
53+
// Long term, we need either
54+
// (a) JS code to not depend on anything outside this directory, or
55+
// (b) Come up with a way to declare this dependency in Buck.
56+
const isInsideProjectRoots =
57+
config.watchFolders.filter(root => modulePath.startsWith(root)).length >
58+
0;
59+
60+
if (isInsideProjectRoots) {
61+
outStream.write(modulePath + '\n');
62+
}
63+
});
64+
return writeToFile
65+
? denodeify(outStream.end).bind(outStream)()
66+
: Promise.resolve();
7067
}
7168

7269
module.exports = {

0 commit comments

Comments
 (0)