pathutils.js 537 B

123456789101112131415161718192021
  1. /*
  2. Copyright 2015, Yahoo Inc.
  3. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
  4. */
  5. 'use strict';
  6. const path = require('path');
  7. module.exports = {
  8. isAbsolute: path.isAbsolute,
  9. asAbsolute(file, baseDir) {
  10. return path.isAbsolute(file)
  11. ? file
  12. : path.resolve(baseDir || process.cwd(), file);
  13. },
  14. relativeTo(file, origFile) {
  15. return path.isAbsolute(file)
  16. ? file
  17. : path.resolve(path.dirname(origFile), file);
  18. }
  19. };