entry.js 871 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const utils = require("../../utils");
  4. class EntryTransformer {
  5. constructor(_settings) {
  6. this._settings = _settings;
  7. }
  8. getTransformer() {
  9. return (entry) => this._transform(entry);
  10. }
  11. _transform(entry) {
  12. let filepath = entry.path;
  13. if (this._settings.absolute) {
  14. filepath = utils.path.makeAbsolute(this._settings.cwd, filepath);
  15. filepath = utils.path.unixify(filepath);
  16. }
  17. if (this._settings.markDirectories && entry.dirent.isDirectory()) {
  18. filepath += '/';
  19. }
  20. if (!this._settings.objectMode) {
  21. return filepath;
  22. }
  23. return Object.assign(Object.assign({}, entry), { path: filepath });
  24. }
  25. }
  26. exports.default = EntryTransformer;