badge-urls
Version:
Helper functions to generate URLs for all badges / shields from shields.io
36 lines (35 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var path_to_regexp_1 = require("path-to-regexp");
var fs_1 = require("../../utils/fs");
var constants_1 = require("../constants");
function main() {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var data, _a, _b, item, keys, regexp, tokens, regexp2, fn;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
_b = (_a = JSON).parse;
return [4 /*yield*/, fs_1.readFile(constants_1.SHIELDS_IO_DATA_FILE, {
encoding: "utf-8",
})];
case 1:
data = _b.apply(_a, [(_c.sent())]);
item = data["activity"][2];
keys = [];
regexp = path_to_regexp_1.pathToRegexp(item.url, keys);
tokens = path_to_regexp_1.parse(item.url);
regexp2 = path_to_regexp_1.tokensToRegexp(tokens);
fn = path_to_regexp_1.tokensToFunction(tokens);
console.log(regexp);
console.log(keys);
console.log(tokens);
console.log(regexp2);
console.log(fn({ interval: "day", user: "gfmio", repo: "example-calculator" }));
return [2 /*return*/];
}
});
});
}
main();