summaryrefslogtreecommitdiffstats
path: root/dom/media/webvtt/update-webvtt.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webvtt/update-webvtt.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webvtt/update-webvtt.js')
-rw-r--r--dom/media/webvtt/update-webvtt.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/media/webvtt/update-webvtt.js b/dom/media/webvtt/update-webvtt.js
new file mode 100644
index 0000000000..20a3e2669f
--- /dev/null
+++ b/dom/media/webvtt/update-webvtt.js
@@ -0,0 +1,61 @@
+#!/usr/bin/env node
+
+/* eslint-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("r", {
+ alias: "rev",
+ describe: "Revision to update to.",
+ default: "master",
+ })
+ .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(argv.r, function () {
+ repo.commits(argv.r, 1, function (err, commits) {
+ var vttjs = fs.readFileSync(argv.d + "/lib/vtt.js", "utf8");
+
+ // 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" +
+ "export var WebVTT;" +
+ "/**\n" +
+ " * Code below is vtt.js the JS WebVTT implementation.\n" +
+ " * Current source code can be found at http://github.com/mozilla/vtt.js\n" +
+ " *\n" +
+ " * Code taken from commit " +
+ commits[0].id +
+ "\n" +
+ " */\n" +
+ vttjs;
+
+ fs.writeFileSync(argv.w, vttjs);
+ });
+ });
+});