getRelativePath.cjs 635 B

123456789101112131415161718
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const path = require('node:path');
  5. /**
  6. * Returns the relative path of a file to the current working directory.
  7. * Always in POSIX format for consistency and interoperability.
  8. * @param {string} cwd The current working directory.
  9. * @param {string} filePath The file path.
  10. * @returns {string} The relative file path.
  11. */
  12. function getRelativePath(cwd, filePath) {
  13. return path.relative(cwd, filePath).split(path.sep).join(path.posix.sep);
  14. }
  15. module.exports = getRelativePath;