Skip to content

Commit

Permalink
fix(NOJIRA-123): post adoption comment if js files are renamed to ts
Browse files Browse the repository at this point in the history
In a PR where a single file is being renamed from file.js to file.ts, even though the TS adoption is changing, the comment is being posted because only the old filename of the changed file ends in .js.
Adds a condition for detecting renames.
  • Loading branch information
trapped authored Sep 29, 2023
2 parents ef0f017 + d92d887 commit 8cf600d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/checks/requiredTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ async function checkPullRequest(): Promise<boolean> {

const files = await github.getPullRequestFiles(pr.number)
const jsFiles = files.filter((f) => isForbiddenJSFile(f.filename, filter))
const renamedJsFiles = files.filter(
(f) =>
f.previous_filename &&
isForbiddenJSFile(f.previous_filename) &&
!jsFiles.includes(f)
)
const tsconfigFiles = await fs.glob({
patterns: ['**/tsconfig.json'],
exclude: filter,
Expand All @@ -74,7 +80,7 @@ async function checkPullRequest(): Promise<boolean> {
)
}

if (jsFiles.length || errors.length > 0) {
if (jsFiles.length || renamedJsFiles.length || errors.length > 0) {
const adoption = await measureTsAdoption(filter)
const commentId = await github.pinComment(
pr.number,
Expand Down

0 comments on commit 8cf600d

Please sign in to comment.