Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
416 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | const { dirname, resolve } = require('path');
|
---|
| 2 | const { readdirSync, statSync } = require('fs');
|
---|
| 3 |
|
---|
| 4 | module.exports = function (start, callback) {
|
---|
| 5 | let dir = resolve('.', start);
|
---|
| 6 | let tmp, stats = statSync(dir);
|
---|
| 7 |
|
---|
| 8 | if (!stats.isDirectory()) {
|
---|
| 9 | dir = dirname(dir);
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | while (true) {
|
---|
| 13 | tmp = callback(dir, readdirSync(dir));
|
---|
| 14 | if (tmp) return resolve(dir, tmp);
|
---|
| 15 | dir = dirname(tmp = dir);
|
---|
| 16 | if (tmp === dir) break;
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.