All files pathUtils.js

100% Statements 8/8
80% Branches 4/5
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301x 1x         1x 2x                   1x 1x           1x 2x        
import appRootPath from 'app-root-path';
import path from 'path';
 
/**
 * @returns {string} - returns the appRoot path
 */
export function appRoot() {
  return (
    (process.mainModule &&
      process.mainModule.paths[0].split('node_modules')[0].slice(0, -1)) ||
    appRootPath
  );
}
 
/**
 * @param {string} dest
 */
export function fromAppRoot(dest) {
  return path.join(appRoot().toString(), dest);
}
 
/**
 * @param {string} dest
 */
export function resolvePath(dest) {
  return ~['~', '/'].indexOf(dest.charAt(0)) ?
    dest :
    path.join(appRoot().toString(), dest);
}