Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// get monorepo root location using esm and .git folder
// Resolve monorepo root from the location of this config file.
// Note: in git worktrees `.git` is a file (not a directory), so we can't rely
// on `findUp(..., { type: "directory" })` always succeeding.
import * as findUp from "find-up";
import path from "path";
import { fileURLToPath } from "url";

const root = path.dirname(await findUp.findUp(".git", { type: "directory" }));
const configDir = path.dirname(fileURLToPath(import.meta.url));
const gitPath =
(await findUp.findUp(".git", { cwd: configDir, type: "directory" })) ??
(await findUp.findUp(".git", { cwd: configDir, type: "file" }));
const root = gitPath ? path.dirname(gitPath) : configDir;

export default {
// global options
Expand Down
8 changes: 7 additions & 1 deletion packages/clients/peerbit/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import * as findUp from "find-up";
import fs from "fs";
import { createRequire } from "module";
import path from "path";
import { fileURLToPath } from "url";

const root = path.dirname(await findUp.findUp(".git", { type: "directory" }));
// In git worktrees `.git` is a file (not a directory), so allow both.
const configDir = path.dirname(fileURLToPath(import.meta.url));
const gitPath =
(await findUp.findUp(".git", { cwd: configDir, type: "directory" })) ??
(await findUp.findUp(".git", { cwd: configDir, type: "file" }));
const root = gitPath ? path.dirname(gitPath) : configDir;
const resolverFromRoot = createRequire(path.join(root, "package.json"));
const resolverFromLocal = createRequire(import.meta.url);

Expand Down
Loading
Loading