1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webvtt/update-webvtt.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +#!/usr/bin/env node 1.5 +var gift = require('gift'), 1.6 + fs = require('fs'), 1.7 + argv = require('optimist') 1.8 + .usage('Update vtt.jsm with the latest from a vtt.js directory.\nUsage:' + 1.9 + ' $0 -d [dir]') 1.10 + .demand('d') 1.11 + .options('d', { 1.12 + alias: 'dir', 1.13 + describe: 'Path to WebVTT directory.' 1.14 + }) 1.15 + .options('w', { 1.16 + alias: 'write', 1.17 + describe: 'Path to file to write to.', 1.18 + default: "./vtt.jsm" 1.19 + }) 1.20 + .argv; 1.21 + 1.22 +var repo = gift(argv.d); 1.23 +repo.status(function(err, status) { 1.24 + if (!status.clean) { 1.25 + console.log("The repository's working directory is not clean. Aborting."); 1.26 + process.exit(1); 1.27 + } 1.28 + repo.checkout("master", function() { 1.29 + repo.commits("master", 1, function(err, commits) { 1.30 + var vttjs = fs.readFileSync(argv.d + "/lib/vtt.js", 'utf8'); 1.31 + 1.32 + // Remove settings for VIM and Emacs. 1.33 + vttjs = vttjs.replace(/\/\* -\*-.*-\*- \*\/\n/, ''); 1.34 + vttjs = vttjs.replace(/\/\* vim:.* \*\/\n/, ''); 1.35 + 1.36 + // Concatenate header and vttjs code. 1.37 + vttjs = 1.38 + '/* This Source Code Form is subject to the terms of the Mozilla Public\n' + 1.39 + ' * License, v. 2.0. If a copy of the MPL was not distributed with this\n' + 1.40 + ' * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\n' + 1.41 + 'this.EXPORTED_SYMBOLS = ["WebVTT"];\n\n' + 1.42 + '/**\n' + 1.43 + ' * Code below is vtt.js the JS WebVTT implementation.\n' + 1.44 + ' * Current source code can be found at http://github.com/mozilla/vtt.js\n' + 1.45 + ' *\n' + 1.46 + ' * Code taken from commit ' + commits[0].id + '\n' + 1.47 + ' */\n' + 1.48 + vttjs; 1.49 + 1.50 + fs.writeFileSync(argv.w, vttjs); 1.51 + }); 1.52 +}); 1.53 +});