Skip to content

Commit

Permalink
Merge pull request #331 from orta/no_dt
Browse files Browse the repository at this point in the history
Don't automatically recommend creating an issue on DefinitelyTyped
  • Loading branch information
orta committed Sep 28, 2022
2 parents 1486859 + ccb353e commit 639b9c8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ patch-package 0.0.0
• Diffing your files with clean files
✔ Created file patches/@microsoft+mezzurite-core++@types+angular+1.6.53.patch
💡 @types/angular is on GitHub! To draft an issue based on your patch run
yarn patch-package @microsoft/mezzurite-core/@types/angular --create-issue
END SNAPSHOT"
`;

Expand Down
28 changes: 28 additions & 0 deletions src/createIssue.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { shouldRecommendIssue } from "./createIssue"

describe(shouldRecommendIssue, () => {
it("Allows most repos", () => {
const eigen = shouldRecommendIssue({
org: "artsy",
repo: "eigen",
provider: "GitHub",
})
expect(eigen).toBeTruthy()

const typescript = shouldRecommendIssue({
org: "Microsoft",
repo: "TypeScript",
provider: "GitHub",
})
expect(typescript).toBeTruthy()
})

it("does not recommend DefinitelyTyped", () => {
const typescript = shouldRecommendIssue({
org: "DefinitelyTyped",
repo: "DefinitelyTyped",
provider: "GitHub",
})
expect(typescript).toBeFalsy()
})
})
16 changes: 15 additions & 1 deletion src/createIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,26 @@ function getPackageVCSDetails(packageDetails: PackageDetails) {
}
}

export function shouldRecommendIssue(
vcsDetails: ReturnType<typeof getPackageVCSDetails>,
) {
if (!vcsDetails) {
return true
}

const { repo, org } = vcsDetails
if (repo === "DefinitelyTyped" && org === "DefinitelyTyped") {
return false
}
return true
}

export function maybePrintIssueCreationPrompt(
packageDetails: PackageDetails,
packageManager: PackageManager,
) {
const vcs = getPackageVCSDetails(packageDetails)
if (vcs) {
if (vcs && shouldRecommendIssue(vcs)) {
console.log(`💡 ${chalk.bold(packageDetails.name)} is on ${
vcs.provider
}! To draft an issue based on your patch run
Expand Down

0 comments on commit 639b9c8

Please sign in to comment.