Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-go / lib / utils / checktag.js
diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/checktag.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/checktag.js
new file mode 100644 (file)
index 0000000..c68a580
--- /dev/null
@@ -0,0 +1,22 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const tslib_1 = require("tslib");
+const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
+const releaseFilter = /^v\d+\.\d+\.\d+$/;
+async function checkLatestTag(repo, prefixFilter) {
+    const resp = await node_fetch_1.default(`https://api.github.com/repos/${repo}/tags`);
+    const data = await resp.json();
+    let tags = data.map(t => t.name);
+    if (prefixFilter) {
+        tags = tags
+            .filter(t => t.match(prefixFilter))
+            .map(t => t.replace(prefixFilter, ''));
+    }
+    tags = tags
+        .filter(t => t.match(releaseFilter));
+    return tags.length > 0
+        ? tags[0].replace(/^v/, '')
+        : '';
+}
+exports.default = checkLatestTag;
+//# sourceMappingURL=checktag.js.map
\ No newline at end of file