codebuff 1.0.510 → 1.0.512
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.
- package/index.js +3 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -93,22 +93,15 @@ function httpGet(url, options = {}) {
|
|
|
93
93
|
async function getLatestVersion() {
|
|
94
94
|
try {
|
|
95
95
|
const res = await httpGet(
|
|
96
|
-
`https://
|
|
96
|
+
`https://registry.npmjs.org/${packageName}/latest`,
|
|
97
97
|
)
|
|
98
98
|
|
|
99
99
|
if (res.statusCode !== 200) return null
|
|
100
100
|
|
|
101
101
|
const body = await streamToString(res)
|
|
102
|
+
const packageData = JSON.parse(body)
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
const tagMatch = body.match(
|
|
105
|
-
/<id>tag:github\.com,2008:Repository\/\d+\/v(\d+\.\d+\.\d+)<\/id>/,
|
|
106
|
-
)
|
|
107
|
-
if (tagMatch && tagMatch[1]) {
|
|
108
|
-
return tagMatch[1]
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return null
|
|
104
|
+
return packageData.version || null
|
|
112
105
|
} catch (error) {
|
|
113
106
|
return null
|
|
114
107
|
}
|