暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718
  1. import { dirname, resolve } from 'path';
  2. import { readdirSync, statSync } from 'fs';
  3. export default function (start, callback) {
  4. let dir = resolve('.', start);
  5. let tmp, stats = statSync(dir);
  6. if (!stats.isDirectory()) {
  7. dir = dirname(dir);
  8. }
  9. while (true) {
  10. tmp = callback(dir, readdirSync(dir));
  11. if (tmp) return resolve(dir, tmp);
  12. dir = dirname(tmp = dir);
  13. if (tmp === dir) break;
  14. }
  15. }