addToFilesOption.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var immutable_1 = require("immutable");
  4. function addToFilesOption(incoming) {
  5. if (!incoming.get("watch")) {
  6. return [incoming, []];
  7. }
  8. var serverPaths = [];
  9. var fromServeStatic = incoming
  10. .get("serveStatic", immutable_1.List([]))
  11. .toArray();
  12. var ssPaths = fromServeStatic
  13. .reduce(function (acc, ss) {
  14. if (typeof ss === "string") {
  15. return acc.concat(ss);
  16. }
  17. if (ss.dir && typeof ss.dir === "string") {
  18. return acc.concat(ss);
  19. }
  20. return acc;
  21. }, []);
  22. ssPaths.forEach(function (p) { return serverPaths.push(p); });
  23. var server = incoming.get("server");
  24. if (server) {
  25. if (server === true) {
  26. serverPaths.push(".");
  27. }
  28. if (typeof server === "string") {
  29. serverPaths.push(server);
  30. }
  31. if (immutable_1.List.isList(server) &&
  32. server.every(function (x) { return typeof x === "string"; })) {
  33. server.forEach(function (s) { return serverPaths.push(s); });
  34. }
  35. if (immutable_1.Map.isMap(server)) {
  36. var baseDirProp = server.get("baseDir");
  37. var baseDirs = immutable_1.List([]).concat(baseDirProp).filter(Boolean);
  38. baseDirs.forEach(function (s) { return serverPaths.push(s); });
  39. }
  40. }
  41. var output = incoming.update("files", function (files) {
  42. return immutable_1.List([])
  43. .concat(files, serverPaths)
  44. .filter(Boolean);
  45. });
  46. return [output, []];
  47. }
  48. exports.addToFilesOption = addToFilesOption;
  49. //# sourceMappingURL=addToFilesOption.js.map