File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change 11const fs = require ( 'fs/promises' )
22
3+ async function getCloneCount ( jsonFile ) {
4+ const result = JSON . parse ( await fs . readFile ( jsonFile , 'utf8' ) )
5+ return result . statistics . total . clones
6+ }
7+
38async function main ( ) {
49 console . log ( `In args with: ${ process . argv } ` )
510 const masterJson = process . argv [ 2 ]
611 const branchJson = process . argv [ 3 ]
712 console . log ( `master report located at ${ masterJson } ` )
813 console . log ( `branch report located at ${ branchJson } ` )
914
10- const masterResult = JSON . parse ( await fs . readFile ( masterJson , 'utf8' ) )
11- const branchResult = JSON . parse ( await fs . readFile ( branchJson , 'utf8' ) )
12-
13- console . log ( 'master' )
14- console . log ( masterResult )
15- console . log ( 'branch' )
16- console . log ( branchResult )
17-
18- const masterClones = masterResult . statistics . total . clones
19- const branchClones = branchResult . statistics . total . clones
15+ const masterClones = await getCloneCount ( masterJson )
16+ const branchClones = await getCloneCount ( branchJson )
2017
2118 console . log ( `total clones on master is: ${ masterClones } ` )
2219 console . log ( `total clones on branch is: ${ branchClones } ` )
2320
2421 if ( masterClones < branchClones ) {
25- console . log ( 'introducing new duplicate code!' )
22+ console . log ( `❌ Copy-Paste Test failed, increasing clone count by ${ masterClones - branchClones } ` )
2623 process . exit ( 1 )
2724 } else {
28- console . log ( 'pass' )
25+ console . log ( `✅ Copy-Paste Test passed` )
2926 }
3027}
3128
Original file line number Diff line number Diff line change 8080 git checkout ${{ github.ref }}
8181 npx jscpd --pattern "packages/**/*.ts" --ignore "**node_modules**,**dist**,**test**" --gitignore --reporters json --output branch
8282 - name : Compare clone count across master and new branch
83- run : |
84- node "$GITHUB_WORKSPACE/.github/workflows/lintdupe.js" master/jscpd-report.json branch/jscpd-report.json
83+ run : node "$GITHUB_WORKSPACE/.github/workflows/lintdupe.js" master/jscpd-report.json branch/jscpd-report.json
8584
8685 macos :
8786 needs : lint-commits
You can’t perform that action at this time.
0 commit comments