mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-01 23:24:12 +01:00
Current file header is : /*! showdown v 2.0.0-alpha1 - 25-09-2018 */ Official 2.0.0-alpha doesn't match neither on content nor date :( Considering date we would be at 1.8.7, but it is also quite different (and has vulnerabilities) In consequence switching to 2.0.0.
23 lines
534 B
JavaScript
23 lines
534 B
JavaScript
const { dirname, resolve } = require('path');
|
|
const { readdir, stat } = require('fs');
|
|
const { promisify } = require('util');
|
|
|
|
const toStats = promisify(stat);
|
|
const toRead = promisify(readdir);
|
|
|
|
module.exports = async function (start, callback) {
|
|
let dir = resolve('.', start);
|
|
let tmp, stats = await toStats(dir);
|
|
|
|
if (!stats.isDirectory()) {
|
|
dir = dirname(dir);
|
|
}
|
|
|
|
while (true) {
|
|
tmp = await callback(dir, await toRead(dir));
|
|
if (tmp) return resolve(dir, tmp);
|
|
dir = dirname(tmp = dir);
|
|
if (tmp === dir) break;
|
|
}
|
|
}
|