src/utils/shared.js
function relativePathArray(filePath, fromPath) {
  filePath = path.normalize(filePath);
  fromPath = path.normalize(fromPath);
  if (filePath.indexOf(fromPath) === -1 || filePath === fromPath) {
    // TODO Error handling: this should cause a warn
    return [];
  }
  const keys = path.relative(fromPath, path.dirname(filePath));
  if (keys && keys.length !== 0) {
    return keys.split(path.sep);
  }
  return [];
}
function relativePathArray(filePath, fromPath) {
  filePath = path.normalize(filePath);
  fromPath = path.normalize(fromPath);
  if (filePath.indexOf(fromPath) === -1 || filePath === fromPath) {
    // TODO Error handling: this should cause a warn
    return [];
  }
  const keys = path.relative(fromPath, path.dirname(filePath));
  if (keys && keys.length !== 0) {
    return keys.split(path.sep);
  }
  return [];
}
function relativePathArray ( filePath , fromPath ) { filePath = path . normalize ( filePath ) ; fromPath = path . normalize ( fromPath ) ; if ( filePath . indexOf ( fromPath ) === - 1 || filePath === fromPath ) { // TODO Error handling: this should cause a warn return [ ] ; } const keys = path . relative ( fromPath , path . dirname ( filePath ) ) ; if ( keys && keys . length !== 0 ) { return keys . split ( path . sep ) ; } return [ ] ; }
Given a file's path and a string representing a directory name,
return an Array that only contains directories at or beneath that
directory.

@example relativePathArray('/foo/bar/baz/ding/dong/tink.txt', 'baz')
// -> ['baz', 'ding', 'dong']
@param {String} filePath
@param {String} fromPath
@return {Array}
Given a file s path and a string representing a directory name return an Array that only contains directories at or beneath that directory .