source: trip-planner-front/node_modules/escalade/dist/index.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 534 bytes
Line 
1const { dirname, resolve } = require('path');
2const { readdir, stat } = require('fs');
3const { promisify } = require('util');
4
5const toStats = promisify(stat);
6const toRead = promisify(readdir);
7
8module.exports = async function (start, callback) {
9 let dir = resolve('.', start);
10 let tmp, stats = await toStats(dir);
11
12 if (!stats.isDirectory()) {
13 dir = dirname(dir);
14 }
15
16 while (true) {
17 tmp = await callback(dir, await toRead(dir));
18 if (tmp) return resolve(dir, tmp);
19 dir = dirname(tmp = dir);
20 if (tmp === dir) break;
21 }
22}
Note: See TracBrowser for help on using the repository browser.