2013-09-17 12:31:00 -07:00
|
|
|
#!/usr/bin/env node
|
|
|
|
var gift = require('gift'),
|
|
|
|
fs = require('fs'),
|
|
|
|
argv = require('optimist')
|
|
|
|
.usage('Update vtt.jsm with the latest from a vtt.js directory.\nUsage:' +
|
|
|
|
' $0 -d [dir]')
|
|
|
|
.demand('d')
|
|
|
|
.options('d', {
|
|
|
|
alias: 'dir',
|
|
|
|
describe: 'Path to WebVTT directory.'
|
|
|
|
})
|
|
|
|
.options('w', {
|
|
|
|
alias: 'write',
|
|
|
|
describe: 'Path to file to write to.',
|
|
|
|
default: "./vtt.jsm"
|
|
|
|
})
|
|
|
|
.argv;
|
|
|
|
|
|
|
|
var repo = gift(argv.d);
|
|
|
|
repo.status(function(err, status) {
|
|
|
|
if (!status.clean) {
|
|
|
|
console.log("The repository's working directory is not clean. Aborting.");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
repo.checkout("master", function() {
|
|
|
|
repo.commits("master", 1, function(err, commits) {
|
2014-03-17 12:11:41 -07:00
|
|
|
var vttjs = fs.readFileSync(argv.d + "/lib/vtt.js", 'utf8');
|
2013-09-17 12:31:00 -07:00
|
|
|
|
|
|
|
// Remove settings for VIM and Emacs.
|
|
|
|
vttjs = vttjs.replace(/\/\* -\*-.*-\*- \*\/\n/, '');
|
|
|
|
vttjs = vttjs.replace(/\/\* vim:.* \*\/\n/, '');
|
|
|
|
|
|
|
|
// Concatenate header and vttjs code.
|
|
|
|
vttjs =
|
|
|
|
'/* This Source Code Form is subject to the terms of the Mozilla Public\n' +
|
|
|
|
' * License, v. 2.0. If a copy of the MPL was not distributed with this\n' +
|
|
|
|
' * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n\n' +
|
2014-03-17 12:11:41 -07:00
|
|
|
'this.EXPORTED_SYMBOLS = ["WebVTT"];\n\n' +
|
2013-09-17 12:31:00 -07:00
|
|
|
'/**\n' +
|
2014-03-17 12:11:41 -07:00
|
|
|
' * Code below is vtt.js the JS WebVTT implementation.\n' +
|
|
|
|
' * Current source code can be found at http://github.com/mozilla/vtt.js\n' +
|
2013-09-17 12:31:00 -07:00
|
|
|
' *\n' +
|
|
|
|
' * Code taken from commit ' + commits[0].id + '\n' +
|
|
|
|
' */\n' +
|
|
|
|
vttjs;
|
|
|
|
|
|
|
|
fs.writeFileSync(argv.w, vttjs);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|