content/media/webvtt/update-webvtt.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial