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
- const pkgCreatedDate = data.time.created
21
- const dateDiff = Date.now() - Date.parse(pkgCreatedDate)
22
-
23
- if (dateDiff < PACKAGE_AGE_THRESHOLD) {
24
- throw new Error(
25
- `detected a newly published package (created < ${PACKAGE_AGE_THRESHOLD} days) act carefully`
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npq",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "marshall your npm/yarn package installs with high quality and class 🎖",
5
5
  "bin": {
6
6
  "npq": "./bin/npq.js",