Skip to content

Commit

Permalink
Require Node.js 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 18, 2019
1 parent a7a9500 commit 80fda88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -6,4 +6,3 @@ language: node_js
node_js:
- '10'
- '8'
- '6'
36 changes: 18 additions & 18 deletions index.js
Expand Up @@ -2,31 +2,31 @@
const path = require('path');
const locatePath = require('locate-path');

module.exports = (name, options = {}) => {
const startDirectory = path.resolve(options.cwd || '');
const {root} = path.parse(startDirectory);

module.exports = async (name, options = {}) => {
let directory = path.resolve(options.cwd || '');
const {root} = path.parse(directory);
const paths = [].concat(name);

return new Promise(resolve => {
(function find(directory) {
locatePath(paths, {cwd: directory}).then(foundPath => {
if (foundPath) {
resolve(path.join(directory, foundPath));
} else if (directory === root) {
resolve();
} else {
find(path.dirname(directory));
}
});
})(startDirectory);
});
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line no-await-in-loop
const foundPath = await locatePath(paths, {cwd: directory});

if (foundPath) {
return path.join(directory, foundPath);
}

if (directory === root) {
return;
}

directory = path.dirname(directory);
}
};

module.exports.sync = (name, options = {}) => {
let directory = path.resolve(options.cwd || '');
const {root} = path.parse(directory);

const paths = [].concat(name);

// eslint-disable-next-line no-constant-condition
Expand Down
7 changes: 3 additions & 4 deletions package.json
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -35,17 +35,16 @@
"parents",
"folder",
"directory",
"dir",
"walk",
"walking",
"path"
],
"dependencies": {
"locate-path": "^3.0.0"
"locate-path": "^4.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tempy": "^0.2.1",
"tempy": "^0.3.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
Expand Down

0 comments on commit 80fda88

Please sign in to comment.