Skip to content

Commit

Permalink
Remove socket interface from dependencies command
Browse files Browse the repository at this point in the history
Reviewed By: davidaurelio

Differential Revision: D3136438

fb-gh-sync-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
fbshipit-source-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
  • Loading branch information
sam-swarr authored and Facebook Github Bot 4 committed Apr 11, 2016
1 parent bc81cc4 commit a35ef6c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 42 deletions.
62 changes: 20 additions & 42 deletions local-cli/dependencies/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,50 +80,28 @@ function _dependencies(argv, config, resolve, reject, packagerInstance) {
? fs.createWriteStream(args.output)
: process.stdout;

if (packagerInstance) {
resolve(packagerInstance.getOrderedDependencyPaths(options).then(
deps => {
return _dependenciesHandler(
deps,
packageOpts.projectRoots,
outStream,
writeToFile
);
}
));
} else {
resolve(ReactPackager.createClientFor(packageOpts).then(client => {
return client.getOrderedDependencyPaths(options)
.then(deps => {
client.close();
return _dependenciesHandler(
deps,
packageOpts.projectRoots,
outStream,
writeToFile
);
});
}));
}
}
resolve((packagerInstance ?
packagerInstance.getOrderedDependencyPaths(options) :
ReactPackager.getOrderedDependencyPaths(packageOpts, 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 = packageOpts.projectRoots.filter(
root => modulePath.startsWith(root)
).length > 0;

function _dependenciesHandler(deps, projectRoots, outStream, writeToFile) {
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 = projectRoots.filter(
root => modulePath.startsWith(root)
).length > 0;

if (isInsideProjectRoots) {
outStream.write(modulePath + '\n');
if (isInsideProjectRoots) {
outStream.write(modulePath + '\n');
}
});
return writeToFile
? Promise.denodeify(outStream.end).bind(outStream)()
: Promise.resolve();
}
});
return writeToFile
? Promise.denodeify(outStream.end).bind(outStream)()
: Promise.resolve();
));
}

module.exports = dependencies;
9 changes: 9 additions & 0 deletions packager/react-packager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ exports.getDependencies = function(options, bundleOptions) {
});
};

exports.getOrderedDependencyPaths = function(options, bundleOptions) {
var server = createNonPersistentServer(options);
return server.getOrderedDependencyPaths(bundleOptions)
.then(function(paths) {
server.end();
return paths;
});
};

exports.createClientFor = function(options) {
if (options.verbose) {
enableDebug();
Expand Down

0 comments on commit a35ef6c

Please sign in to comment.