metro/react-packager/index.js

40 lines
936 B
JavaScript
Raw Normal View History

'use strict';
2015-01-30 01:10:49 +00:00
var Activity = require('./src/Activity');
var Server = require('./src/Server');
2015-01-30 01:10:49 +00:00
exports.middleware = function(options) {
var server = new Server(options);
return server.processRequest.bind(server);
2015-01-30 01:10:49 +00:00
};
exports.buildPackageFromUrl = function(options, reqUrl) {
Activity.disable();
// Don't start the filewatcher or the cache.
if (options.nonPersistent == null) {
options.nonPersistent = true;
}
var server = new Server(options);
return server.buildPackageFromUrl(reqUrl)
.then(function(p) {
server.end();
return p;
});
2015-01-30 01:10:49 +00:00
};
exports.getDependencies = function(options, main) {
Activity.disable();
// Don't start the filewatcher or the cache.
if (options.nonPersistent == null) {
options.nonPersistent = true;
}
var server = new Server(options);
return server.getDependencies(main)
.then(function(r) {
server.end();
return r.dependencies;
});
};