Remove socket interface from dependencies command

Reviewed By: davidaurelio

Differential Revision: D3136438

fb-gh-sync-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
fbshipit-source-id: 51fce2caf60fdf32a8cba180c79b1996834cda6e
This commit is contained in:
Sam Swarr 2016-04-11 09:23:06 -07:00 коммит произвёл Facebook Github Bot 4
Родитель bc81cc4073
Коммит a35ef6c745
2 изменённых файлов: 29 добавлений и 42 удалений

Просмотреть файл

@ -80,50 +80,28 @@ function _dependencies(argv, config, resolve, reject, packagerInstance) {
? fs.createWriteStream(args.output) ? fs.createWriteStream(args.output)
: process.stdout; : process.stdout;
if (packagerInstance) { resolve((packagerInstance ?
resolve(packagerInstance.getOrderedDependencyPaths(options).then( packagerInstance.getOrderedDependencyPaths(options) :
deps => { ReactPackager.getOrderedDependencyPaths(packageOpts, options)).then(
return _dependenciesHandler( deps => {
deps, deps.forEach(modulePath => {
packageOpts.projectRoots, // Temporary hack to disable listing dependencies not under this directory.
outStream, // Long term, we need either
writeToFile // (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)
} else { ).length > 0;
resolve(ReactPackager.createClientFor(packageOpts).then(client => {
return client.getOrderedDependencyPaths(options)
.then(deps => {
client.close();
return _dependenciesHandler(
deps,
packageOpts.projectRoots,
outStream,
writeToFile
);
});
}));
}
}
function _dependenciesHandler(deps, projectRoots, outStream, writeToFile) { if (isInsideProjectRoots) {
deps.forEach(modulePath => { outStream.write(modulePath + '\n');
// 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 return writeToFile
// (b) Come up with a way to declare this dependency in Buck. ? Promise.denodeify(outStream.end).bind(outStream)()
const isInsideProjectRoots = projectRoots.filter( : Promise.resolve();
root => modulePath.startsWith(root)
).length > 0;
if (isInsideProjectRoots) {
outStream.write(modulePath + '\n');
} }
}); ));
return writeToFile
? Promise.denodeify(outStream.end).bind(outStream)()
: Promise.resolve();
} }
module.exports = dependencies; module.exports = dependencies;

9
packager/react-packager/index.js поставляемый
Просмотреть файл

@ -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) { exports.createClientFor = function(options) {
if (options.verbose) { if (options.verbose) {
enableDebug(); enableDebug();