Explorar el Código

add --output-directory option

Gildas hace 5 años
padre
commit
1dceba7195
Se han modificado 2 ficheros con 9 adiciones y 2 borrados
  1. 4 1
      cli/args.js
  2. 5 1
      cli/single-file-cli-api.js

+ 4 - 1
cli/args.js

@@ -79,7 +79,8 @@ const args = require("yargs")
 		"crawl-max-depth": 1,
 		"crawl-external-links-max-depth": 1,
 		"crawl-replace-urls": false,
-		"crawl-rewrite-rules": []
+		"crawl-rewrite-rules": [],
+		"output-directory": ""
 	})
 	.options("back-end", { description: "Back-end to use" })
 	.choices("back-end", ["jsdom", "puppeteer", "webdriver-chromium", "webdriver-gecko", "puppeteer-firefox", "playwright-firefox", "playwright-chromium"])
@@ -196,6 +197,8 @@ const args = require("yargs")
 	.boolean("user-script-enabled")
 	.options("web-driver-executable-path", { description: "Path to Selenium WebDriver executable (webdriver-gecko, webdriver-chromium)" })
 	.string("web-driver-executable-path")
+	.options("output-directory", { description: "Path to where to save files, this path must exist." })
+	.string("output-directory")	
 	.argv;
 args.compressCSS = args.compressCss;
 args.compressHTML = args.compressHtml;

+ 5 - 1
cli/single-file-cli-api.js

@@ -227,7 +227,11 @@ async function capturePage(options) {
 }
 
 function getFilename(filename, options, index = 1) {
-	let newFilename = filename;
+	let outputDirectory = options.outputDirectory;
+	if (outputDirectory && !outputDirectory.endsWith("/")) {
+		outputDirectory += "/";
+	}
+	let newFilename = outputDirectory + filename;
 	if (options.filenameConflictAction == "overwrite") {
 		return filename;
 	} else if (options.filenameConflictAction == "uniquify" && index > 1) {