content/media/webvtt/update-webvtt.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/usr/bin/env node
michael@0 2 var gift = require('gift'),
michael@0 3 fs = require('fs'),
michael@0 4 argv = require('optimist')
michael@0 5 .usage('Update vtt.jsm with the latest from a vtt.js directory.\nUsage:' +
michael@0 6 ' $0 -d [dir]')
michael@0 7 .demand('d')
michael@0 8 .options('d', {
michael@0 9 alias: 'dir',
michael@0 10 describe: 'Path to WebVTT directory.'
michael@0 11 })
michael@0 12 .options('w', {
michael@0 13 alias: 'write',
michael@0 14 describe: 'Path to file to write to.',
michael@0 15 default: "./vtt.jsm"
michael@0 16 })
michael@0 17 .argv;
michael@0 18
michael@0 19 var repo = gift(argv.d);
michael@0 20 repo.status(function(err, status) {
michael@0 21 if (!status.clean) {
michael@0 22 console.log("The repository's working directory is not clean. Aborting.");
michael@0 23 process.exit(1);
michael@0 24 }
michael@0 25 repo.checkout("master", function() {
michael@0 26 repo.commits("master", 1, function(err, commits) {
michael@0 27 var vttjs = fs.readFileSync(argv.d + "/lib/vtt.js", 'utf8');
michael@0 28
michael@0 29 // Remove settings for VIM and Emacs.
michael@0 30 vttjs = vttjs.replace(/\/\* -\*-.*-\*- \*\/\n/, '');
michael@0 31 vttjs = vttjs.replace(/\/\* vim:.* \*\/\n/, '');
michael@0 32
michael@0 33 // Concatenate header and vttjs code.
michael@0 34 vttjs =
michael@0 35 '/* This Source Code Form is subject to the terms of the Mozilla Public\n' +
michael@0 36 ' * License, v. 2.0. If a copy of the MPL was not distributed with this\n' +
michael@0 37 ' * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\n' +
michael@0 38 'this.EXPORTED_SYMBOLS = ["WebVTT"];\n\n' +
michael@0 39 '/**\n' +
michael@0 40 ' * Code below is vtt.js the JS WebVTT implementation.\n' +
michael@0 41 ' * Current source code can be found at http://github.com/mozilla/vtt.js\n' +
michael@0 42 ' *\n' +
michael@0 43 ' * Code taken from commit ' + commits[0].id + '\n' +
michael@0 44 ' */\n' +
michael@0 45 vttjs;
michael@0 46
michael@0 47 fs.writeFileSync(argv.w, vttjs);
michael@0 48 });
michael@0 49 });
michael@0 50 });

mercurial