Description: Support commander >= 14
 In commander v14, require("commander") no longer returns a Command instance.
 Use require("commander").program instead, access option values via .opts(),
 and allow excess arguments (previously implicit, now strict by default).
Author: Yadd <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2026-04-07
--- a/commoner/lib/commoner.js
+++ b/commoner/lib/commoner.js
@@ -198,7 +198,8 @@
 };
 
 function cliBuildP(commoner, version) {
-    var options = require("commander");
+    var options = require("commander").program;
+    options.allowExcessArguments(true);
     var workingDir = process.cwd();
     var sourceDir = workingDir;
     var outputDir = null;
@@ -225,18 +226,19 @@
     });
 
     options.parse(process.argv.slice(0));
+    var optValues = options.opts();
 
-    var pfe = new PreferredFileExtension(options.extension || "js");
+    var pfe = new PreferredFileExtension(optValues.extension || "js");
 
     // TODO Decide whether passing options to buildP via instance
     // variables is preferable to passing them as arguments.
     commoner.preferredFileExtension = pfe;
-    commoner.watch = options.watch;
-    commoner.ignoreDependencies = !options.followRequires;
-    commoner.relativize = options.relativize;
-    commoner.useProvidesModule = options.useProvidesModule;
-    commoner.sourceCharset = normalizeCharset(options.sourceCharset);
-    commoner.outputCharset = normalizeCharset(options.outputCharset);
+    commoner.watch = optValues.watch;
+    commoner.ignoreDependencies = !optValues.followRequires;
+    commoner.relativize = optValues.relativize;
+    commoner.useProvidesModule = optValues.useProvidesModule;
+    commoner.sourceCharset = normalizeCharset(optValues.sourceCharset);
+    commoner.outputCharset = normalizeCharset(optValues.outputCharset);
 
     function fileToId(file) {
         file = absolutePath(workingDir, file);
@@ -247,7 +249,7 @@
     var args = options.args.slice(0);
     var argc = args.length;
     if (argc === 0) {
-        if (options.config === true) {
+        if (optValues.config === true) {
             log.err("Cannot read --config from STDIN when reading " +
                     "source from STDIN");
             process.exit(-1);
@@ -292,10 +294,10 @@
     }
 
     commoner.cacheDir = null;
-    if (options.cacheDir === false) {
+    if (optValues.cacheDir === false) {
         // Received the --no-cache-dir option, so disable the disk cache.
-    } else if (typeof options.cacheDir === "string") {
-        commoner.cacheDir = absolutePath(workingDir, options.cacheDir);
+    } else if (typeof optValues.cacheDir === "string") {
+        commoner.cacheDir = absolutePath(workingDir, optValues.cacheDir);
     } else if (outputDir) {
         // The default cache directory lives inside the output directory.
         commoner.cacheDir = path.join(outputDir, ".module-cache");
@@ -303,14 +305,14 @@
 
     var promise = getConfigP(
         workingDir,
-        options.config
+        optValues.config
     ).then(function(config) {
         var cleanOptions = {};
 
         options.options.forEach(function(option) {
             var name = util.camelize(option.name());
-            if (options.hasOwnProperty(name)) {
-                cleanOptions[name] = options[name];
+            if (optValues.hasOwnProperty(name)) {
+                cleanOptions[name] = optValues[name];
             }
         });
 
