single-file-cli 2.0.12 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/lib/browser.js +7 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/single-file-launcher.js +49 -44
package/deno.json
CHANGED
package/lib/browser.js
CHANGED
|
@@ -66,7 +66,13 @@ async function launchBrowser(options = {}, indexPath = 0) {
|
|
|
66
66
|
if (indexPath + 1 < BROWSER_PATHS[build.os].length) {
|
|
67
67
|
await launchBrowser(options, indexPath + 1);
|
|
68
68
|
} else {
|
|
69
|
-
|
|
69
|
+
let message = "Chromium executable not found. ";
|
|
70
|
+
if (options.executablePath) {
|
|
71
|
+
message += "Make sure --browser-executable-path is correct.";
|
|
72
|
+
} else {
|
|
73
|
+
message += "Set the path using the --browser-executable-path option.";
|
|
74
|
+
}
|
|
75
|
+
throw new Error(message);
|
|
70
76
|
}
|
|
71
77
|
} else {
|
|
72
78
|
throw error;
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.0.
|
|
1
|
+
export const version = "2.0.14";
|
package/package.json
CHANGED
package/single-file-launcher.js
CHANGED
|
@@ -27,59 +27,64 @@ import { VALID_URL_TEST, initialize } from "./single-file-cli-api.js";
|
|
|
27
27
|
import { Deno, path } from "./lib/deno-polyfill.js";
|
|
28
28
|
import options from "./options.js";
|
|
29
29
|
|
|
30
|
-
const { readTextFile } = Deno;
|
|
30
|
+
const { readTextFile, exit } = Deno;
|
|
31
31
|
const { toFileUrl } = path;
|
|
32
32
|
|
|
33
33
|
export { run };
|
|
34
34
|
|
|
35
35
|
async function run() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
options.url
|
|
39
|
-
|
|
40
|
-
if (options.urlsFile) {
|
|
41
|
-
urls = (await readTextFile(options.urlsFile)).split("\n");
|
|
42
|
-
} else {
|
|
43
|
-
urls = [options.url];
|
|
44
|
-
}
|
|
45
|
-
if (options.browserCookies) {
|
|
46
|
-
const cookies = [];
|
|
47
|
-
for (const cookie of options.browserCookies) {
|
|
48
|
-
const [name, value, domain, path, expires, httpOnly, secure, sameSite, url] = cookie.split(",");
|
|
49
|
-
cookies.push({
|
|
50
|
-
name,
|
|
51
|
-
value,
|
|
52
|
-
url,
|
|
53
|
-
domain,
|
|
54
|
-
path,
|
|
55
|
-
secure,
|
|
56
|
-
httpOnly,
|
|
57
|
-
sameSite,
|
|
58
|
-
expires
|
|
59
|
-
});
|
|
36
|
+
try {
|
|
37
|
+
let urls;
|
|
38
|
+
if (options.url && !VALID_URL_TEST.test(options.url)) {
|
|
39
|
+
options.url = (await toFileUrl(new URL(options.url, import.meta.url).pathname)).href;
|
|
60
40
|
}
|
|
61
|
-
options.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
options.browserCookies = JSON.parse(cookiesContent);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
options.browserCookies = parseCookies(cookiesContent);
|
|
41
|
+
if (options.urlsFile) {
|
|
42
|
+
urls = (await readTextFile(options.urlsFile)).split("\n");
|
|
43
|
+
} else {
|
|
44
|
+
urls = [options.url];
|
|
69
45
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
46
|
+
if (options.browserCookies) {
|
|
47
|
+
const cookies = [];
|
|
48
|
+
for (const cookie of options.browserCookies) {
|
|
49
|
+
const [name, value, domain, path, expires, httpOnly, secure, sameSite, url] = cookie.split(",");
|
|
50
|
+
cookies.push({
|
|
51
|
+
name,
|
|
52
|
+
value,
|
|
53
|
+
url,
|
|
54
|
+
domain,
|
|
55
|
+
path,
|
|
56
|
+
secure,
|
|
57
|
+
httpOnly,
|
|
58
|
+
sameSite,
|
|
59
|
+
expires
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
options.browserCookies = cookies;
|
|
63
|
+
}
|
|
64
|
+
if (options.browserCookiesFile) {
|
|
65
|
+
const cookiesContent = await readTextFile(options.browserCookiesFile);
|
|
66
|
+
try {
|
|
67
|
+
options.browserCookies = JSON.parse(cookiesContent);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
options.browserCookies = parseCookies(cookiesContent);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (options.httpHeaders) {
|
|
73
|
+
const headers = {};
|
|
74
|
+
for (const header of options.httpHeaders) {
|
|
75
|
+
const [name, value] = header.split("=");
|
|
76
|
+
headers[name] = value.trim();
|
|
77
|
+
}
|
|
78
|
+
options.httpHeaders = headers;
|
|
76
79
|
}
|
|
77
|
-
options.
|
|
80
|
+
options.retrieveLinks = true;
|
|
81
|
+
const singlefile = await initialize(options);
|
|
82
|
+
await singlefile.capture(urls);
|
|
83
|
+
await singlefile.finish();
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error.message || error); // eslint-disable-line no-console
|
|
86
|
+
exit(-1);
|
|
78
87
|
}
|
|
79
|
-
options.retrieveLinks = true;
|
|
80
|
-
const singlefile = await initialize(options);
|
|
81
|
-
await singlefile.capture(urls);
|
|
82
|
-
await singlefile.finish();
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
function parseCookies(textValue) {
|