npq 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,16 +17,20 @@ class Marshall extends BaseMarshall {
|
|
|
17
17
|
|
|
18
18
|
validate (pkg) {
|
|
19
19
|
return this.packageRepoUtils.getPackageInfo(pkg.packageName).then((data) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
if (data && data.time && data.time.created) {
|
|
21
|
+
const pkgCreatedDate = data.time.created
|
|
22
|
+
const dateDiff = Date.now() - Date.parse(pkgCreatedDate)
|
|
23
|
+
|
|
24
|
+
if (dateDiff < PACKAGE_AGE_THRESHOLD) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`detected a newly published package (created < ${PACKAGE_AGE_THRESHOLD} days) act carefully`
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return dateDiff
|
|
31
|
+
} else {
|
|
32
|
+
throw new Error('could not determine package age')
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
return dateDiff
|
|
30
34
|
})
|
|
31
35
|
}
|
|
32
36
|
}
|