ember-cli/ember-cli

View on GitHub
lib/utilities/walk-up-path.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
'use strict';

const path = require('path');

let regex = /^[./]$/;

function walkUp(thePath) {
  let paths = [];

  let currentPath = thePath;
  // eslint-disable-next-line no-constant-condition
  while (true) {
    currentPath = path.dirname(currentPath);
    if (regex.test(currentPath)) {
      break;
    }
    paths.push(currentPath);
  }

  return paths;
}

module.exports = walkUp;