[tor-commits] [snowflake-webext/master] Add version meta tag to embed.html when building

arlo at torproject.org arlo at torproject.org
Thu May 7 14:35:59 UTC 2020


commit 5aa149724e66ace86a6a548c50f7800e8f772749
Author: Arlo Breault <arlolra at gmail.com>
Date:   Wed May 6 16:09:39 2020 -0400

    Add version meta tag to embed.html when building
    
    Trac: 34128
---
 make.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/make.js b/make.js
index 5cf38e4..e27871d 100755
--- a/make.js
+++ b/make.js
@@ -2,7 +2,7 @@
 
 /* global require, process */
 
-var { writeFileSync, readdirSync, statSync } = require('fs');
+var { writeFileSync, readFileSync, readdirSync, statSync } = require('fs');
 var { execSync, spawn } = require('child_process');
 var cldr = require('cldr');
 
@@ -119,10 +119,19 @@ task('test', 'snowflake unit tests', function() {
   });
 });
 
+var addVersion = function(dir) {
+  var file = `${dir}/embed.html`;
+  var embed = readFileSync(file, 'utf8');
+  var pkg = require('./package.json');
+  embed = embed.replace(/<\/head>/, `  <meta name="version" content="${pkg.version}" />\n  $&`);
+  writeFileSync(file, embed, 'utf8');
+};
+
 task('build', 'build the snowflake proxy', function() {
   const outDir = 'build';
   execSync(`rm -rf ${outDir}`);
   execSync(`cp -r ${STATIC}/ ${outDir}/`);
+  addVersion(outDir);
   copyTranslations(outDir);
   concatJS(outDir, 'badge', 'embed.js', availableLangs());
   writeFileSync(`${outDir}/index.js`, translatedLangs(), 'utf8');



More information about the tor-commits mailing list