path.js 810 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var path = require("path");
  4. /**
  5. * Returns «true» if the last partial of the path starting with a period.
  6. */
  7. function isDotDirectory(filepath) {
  8. return path.basename(filepath).startsWith('.');
  9. }
  10. exports.isDotDirectory = isDotDirectory;
  11. /**
  12. * Return naive depth of provided filepath.
  13. */
  14. function getDepth(filepath) {
  15. return filepath.split('/').length;
  16. }
  17. exports.getDepth = getDepth;
  18. /**
  19. * Return resolved a sequence of paths segments into an absolute path.
  20. */
  21. function resolve(from, to) {
  22. return path.resolve(from, to);
  23. }
  24. exports.resolve = resolve;
  25. /**
  26. * Convert a windows-like path to a unix-style path.
  27. */
  28. function normalize(filepath) {
  29. return filepath.replace(/\\/g, '/');
  30. }
  31. exports.normalize = normalize;