output.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var assert = require("assert");
  2. var util = require("./util");
  3. var log = util.log;
  4. function AbstractOutput() {
  5. assert.ok(this instanceof AbstractOutput);
  6. Object.defineProperties(this, {
  7. outputModule: { value: this.outputModule.bind(this) }
  8. });
  9. }
  10. var AOp = AbstractOutput.prototype;
  11. exports.AbstractOutput = AbstractOutput;
  12. AOp.outputModule = function(module) {
  13. throw new Error("not implemented");
  14. };
  15. function StdOutput() {
  16. assert.ok(this instanceof StdOutput);
  17. AbstractOutput.call(this);
  18. }
  19. var SOp = util.inherits(StdOutput, AbstractOutput);
  20. exports.StdOutput = StdOutput;
  21. SOp.outputModule = function(module) {
  22. log.out(module.source);
  23. };
  24. function DirOutput(outputDir) {
  25. assert.ok(this instanceof DirOutput);
  26. assert.strictEqual(typeof outputDir, "string");
  27. AbstractOutput.call(this);
  28. Object.defineProperties(this, {
  29. outputDir: { value: outputDir }
  30. });
  31. }
  32. var DOp = util.inherits(DirOutput, AbstractOutput);
  33. exports.DirOutput = DirOutput;
  34. DOp.outputModule = function(module) {
  35. return module.writeVersionP(this.outputDir);
  36. };
  37. function TestOutput() {
  38. assert.ok(this instanceof TestOutput);
  39. AbstractOutput.call(this);
  40. }
  41. var TOp = util.inherits(TestOutput, AbstractOutput);
  42. exports.TestOutput = TestOutput;
  43. TOp.outputModule = function(module) {
  44. // Swallow any output.
  45. };