CwdFS.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CwdFS = void 0;
  4. const NodeFS_1 = require("./NodeFS");
  5. const ProxiedFS_1 = require("./ProxiedFS");
  6. const path_1 = require("./path");
  7. class CwdFS extends ProxiedFS_1.ProxiedFS {
  8. constructor(target, { baseFs = new NodeFS_1.NodeFS() } = {}) {
  9. super(path_1.ppath);
  10. this.target = this.pathUtils.normalize(target);
  11. this.baseFs = baseFs;
  12. }
  13. getRealPath() {
  14. return this.pathUtils.resolve(this.baseFs.getRealPath(), this.target);
  15. }
  16. resolve(p) {
  17. if (this.pathUtils.isAbsolute(p)) {
  18. return path_1.ppath.normalize(p);
  19. }
  20. else {
  21. return this.baseFs.resolve(path_1.ppath.join(this.target, p));
  22. }
  23. }
  24. mapFromBase(path) {
  25. return path;
  26. }
  27. mapToBase(path) {
  28. if (this.pathUtils.isAbsolute(path)) {
  29. return path;
  30. }
  31. else {
  32. return this.pathUtils.join(this.target, path);
  33. }
  34. }
  35. }
  36. exports.CwdFS = CwdFS;