1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const path_1 = __importDefault(require("path"));
|
7 | const find_up_1 = __importDefault(require("find-up"));
|
8 | exports.default = toplevel;
|
9 |
|
10 |
|
11 |
|
12 | async function toplevel(cwd) {
|
13 | const found = await searchDotGit(cwd);
|
14 | if (typeof found !== 'string') {
|
15 | return found;
|
16 | }
|
17 | return path_1.default.join(found, '..');
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 | async function searchDotGit(cwd) {
|
23 | const foundFile = await find_up_1.default('.git', { cwd, type: 'file' });
|
24 | const foundDir = await find_up_1.default('.git', { cwd, type: 'directory' });
|
25 | return foundFile || foundDir;
|
26 | }
|
27 |
|
\ | No newline at end of file |