Bez popisu

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "build", {
  6. enumerable: true,
  7. get: function() {
  8. return build;
  9. }
  10. });
  11. const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
  12. const _path = /*#__PURE__*/ _interop_require_default(require("path"));
  13. const _resolveConfigPath = require("../../../util/resolveConfigPath");
  14. const _plugin = require("./plugin");
  15. function _interop_require_default(obj) {
  16. return obj && obj.__esModule ? obj : {
  17. default: obj
  18. };
  19. }
  20. async function build(args) {
  21. let input = args["--input"];
  22. let shouldWatch = args["--watch"];
  23. // TODO: Deprecate this in future versions
  24. if (!input && args["_"][1]) {
  25. console.error("[deprecation] Running tailwindcss without -i, please provide an input file.");
  26. input = args["--input"] = args["_"][1];
  27. }
  28. if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
  29. console.error(`Specified input file ${args["--input"]} does not exist.`);
  30. process.exit(9);
  31. }
  32. if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
  33. console.error(`Specified config file ${args["--config"]} does not exist.`);
  34. process.exit(9);
  35. }
  36. // TODO: Reference the @config path here if exists
  37. let configPath = args["--config"] ? args["--config"] : (0, _resolveConfigPath.resolveDefaultConfigPath)();
  38. let processor = await (0, _plugin.createProcessor)(args, configPath);
  39. if (shouldWatch) {
  40. // Abort the watcher if stdin is closed to avoid zombie processes
  41. // You can disable this behavior with --watch=always
  42. if (args["--watch"] !== "always") {
  43. process.stdin.on("end", ()=>process.exit(0));
  44. }
  45. process.stdin.resume();
  46. await processor.watch();
  47. } else {
  48. await processor.build().catch((e)=>{
  49. console.error(e);
  50. process.exit(1);
  51. });
  52. }
  53. }