Skip to content

fix(check:policy): Use relative paths in package.json repository field #24887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,13 @@ export const handlers: Handler[] = [

return undefined;
},
resolver: (file: string): { resolved: boolean } => {
resolver: (file: string, gitRoot: string): { resolved: boolean } => {
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resolver signature was changed to include gitRoot, but the Handler interface and any call sites need to be updated accordingly to prevent type mismatches or runtime errors.

Copilot uses AI. Check for mistakes.

updatePackageJsonFile(path.dirname(file), (json) => {
json.author = author;
json.license = licenseId;

// file is already relative to the repo root, so we can use it as-is.
const relativePkgDir = path.dirname(file).replace(/\\/g, "/");
// file is absolute path, so make relative to the repo root
const relativePkgDir = path.dirname(path.relative(gitRoot, file)).replace(/\\/g, "/");
json.repository =
// The directory field should be omitted from the root package.
relativePkgDir === "."
Expand Down