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