local-resolve-helper.js 412 B

12345678910111213141516
  1. const path = require('path')
  2. /**
  3. * Resolves the path to the file locally.
  4. *
  5. * @param {String} to - the name of the file to resolve to
  6. * @param {String} localPath - the local path
  7. * @returns {String} path - path to the file to import
  8. */
  9. module.exports = function localResolve (to, localPath) {
  10. if (path.isAbsolute(localPath)) {
  11. return localPath
  12. }
  13. return path.join(path.dirname(to), localPath)
  14. }