Link the version text to the PR or changelog entry

This commit is contained in:
Jed Fox authored and GitHub committed 2017-12-24 12:05:54 -05:00
1 parent eb30207fe5
commit 9cbaecbb1e
1 file changed
+19 -1
+19 -1
View File
@@ -83,7 +83,25 @@ window.onload = function() {
worker.onmessage = function(message) {
if (prettierVersion === "?") {
prettierVersion = message.data.version;
document.getElementById("version").textContent = prettierVersion;
var link = document.createElement("a");
var match = prettierVersion.match(/^pr-(\d+)$/);
if (match) {
link.href = "https://github.com/prettier/prettier/pull/" + match[1];
link.textContent = "PR #" + match[1];
} else {
if (prettierVersion.match(/\.0$/)) {
link.href =
"https://github.com/prettier/prettier/releases/tag/" +
prettierVersion;
} else {
link.href =
"https://github.com/j-f1/forked-prettier/blob/master/CHANGELOG.md#" +
prettierVersion;
}
link.textContent = "v" + prettierVersion;
}
document.getElementById("version").appendChild(link);
}
if (outputEditor && docEditor && astEditor) {
outputEditor.setValue(message.data.formatted);