Skip to content

Commit 6c5f547

Browse files
author
AvrAlexandra
committed
refactored and fixed build error
1 parent 9a8048f commit 6c5f547

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

package-lock.json

Lines changed: 2 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"commander": "^11.1.0",
4646
"cross-env": "^7.0.3",
4747
"csv": "^6.0.4",
48-
"date-fns": "^4.1.0",
4948
"dotenv": "^16.0.3",
5049
"isomorphic-git": "^1.27.1",
5150
"lodash": "^4.17.21",
@@ -96,7 +95,7 @@
9695
"sort-package-json": "^1.52.0",
9796
"ts-jest": "^27.0.5",
9897
"ts-node": "^10.2.1",
99-
"typescript": "^4.9.5"
98+
"typescript": "^4.4.3"
10099
},
101100
"publishConfig": {
102101
"registry": "https://npm.pkg.github.com"

src/commands/history-metrics/metrics-generator.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
import {LibraryInfo} from "../../extension-points/registrar"
22
import semver from 'semver'
3-
import { differenceInBusinessDays, parseISO } from "date-fns"
3+
import moment from 'moment'
4+
5+
function differenceInBusinessDays(laterDate: Date, earlierDate: Date): number {
6+
const start = moment(earlierDate);
7+
const end = moment(laterDate);
8+
let businessDays = 0;
9+
10+
while (start.isBefore(end)) {
11+
const dayOfWeek = start.day();
12+
if (dayOfWeek !== 0 && dayOfWeek !== 6) {
13+
businessDays++;
14+
}
15+
start.add(1, 'day');
16+
}
17+
18+
return businessDays;
19+
}
20+
21+
function parseISO(dateString: string): Date {
22+
return new Date(dateString);
23+
}
424

525
export function GrowthPatternMetric(data: CommitDependencyHistory): any {
626
const summary: Record<string, any> = {};

0 commit comments

Comments
 (0)