Skip to content

Commit

Permalink
Download page: Add version number at the beginning of the generated f…
Browse files Browse the repository at this point in the history
…iles. Fix #788
  • Loading branch information
Golmote committed Dec 5, 2017
1 parent f986551 commit 928790d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions download.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ function generateCode(){
var error = $('#download .error');
error.style.display = '';

buildCode(promises).then(function(res) {
Promise.all([buildCode(promises), getVersion()]).then(function(arr) {
var res = arr[0];
var version = arr[1];
var code = res.code;
var errors = res.errors;

Expand All @@ -468,7 +470,7 @@ function generateCode(){
for (var category in redownload) {
redownloadUrl += category + "=" + redownload[category].join('+') + "&";
}
redownloadUrl = "/* " + redownloadUrl.replace(/&$/,"") + " */";
redownloadUrl = "/* PrismJS " + version + "\n" + redownloadUrl.replace(/&$/,"") + " */";

for (var type in code) {
var codeElement = $('#download-' + type + ' code');
Expand Down Expand Up @@ -513,4 +515,10 @@ function buildCode(promises) {
return new Promise(f);
}

function getVersion() {
return getFileContents('./package.json').then(function (jsonStr) {
return JSON.parse(jsonStr).version;
});
}

})();

0 comments on commit 928790d

Please sign in to comment.