single-file-cli 2.0.13 → 2.0.15
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/deno-polyfill.js +11 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/single-file-cli-api.js +7 -3
- package/single-file-launcher.js +2 -1
package/deno.json
CHANGED
package/lib/deno-polyfill.js
CHANGED
|
@@ -101,6 +101,7 @@ const DenoAPI = {
|
|
|
101
101
|
args,
|
|
102
102
|
readTextFile,
|
|
103
103
|
writeTextFile,
|
|
104
|
+
writeFile,
|
|
104
105
|
mkdir,
|
|
105
106
|
makeTempDir,
|
|
106
107
|
stat,
|
|
@@ -144,6 +145,7 @@ async function writeTextFile(path, data, options = {}) {
|
|
|
144
145
|
return Deno.writeTextFile(path, data, options);
|
|
145
146
|
} else {
|
|
146
147
|
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
148
|
+
options.encoding = "utf8";
|
|
147
149
|
if (options.append) {
|
|
148
150
|
return fsPromise.appendFile(path, data, options);
|
|
149
151
|
} else {
|
|
@@ -152,6 +154,15 @@ async function writeTextFile(path, data, options = {}) {
|
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
async function writeFile(path, data, options = {}) {
|
|
158
|
+
if (DENO_RUNTIME_DETECTED) {
|
|
159
|
+
return Deno.writeFile(path, data, options);
|
|
160
|
+
} else {
|
|
161
|
+
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
162
|
+
return fsPromise.writeFile(path, data, options);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
155
166
|
async function mkdir(path, options = {}) {
|
|
156
167
|
if (DENO_RUNTIME_DETECTED) {
|
|
157
168
|
return Deno.mkdir(path, options);
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.0.
|
|
1
|
+
export const version = "2.0.15";
|
package/package.json
CHANGED
package/single-file-cli-api.js
CHANGED
|
@@ -76,7 +76,7 @@ const DEFAULT_OPTIONS = {
|
|
|
76
76
|
const STATE_PROCESSING = "processing";
|
|
77
77
|
const STATE_PROCESSED = "processed";
|
|
78
78
|
|
|
79
|
-
const { readTextFile, writeTextFile, stdout, mkdir, stat } = Deno;
|
|
79
|
+
const { readTextFile, writeTextFile, writeFile, stdout, mkdir, stat } = Deno;
|
|
80
80
|
let tasks = [], maxParallelWorkers, sessionFilename;
|
|
81
81
|
|
|
82
82
|
export { DEFAULT_OPTIONS, VALID_URL_TEST, initialize };
|
|
@@ -240,7 +240,7 @@ function getHostURL(url) {
|
|
|
240
240
|
async function capturePage(options) {
|
|
241
241
|
try {
|
|
242
242
|
let filename;
|
|
243
|
-
options.zipScript = getZipScriptSource();
|
|
243
|
+
options.zipScript = await getZipScriptSource();
|
|
244
244
|
const pageData = await backend.getPageData(options);
|
|
245
245
|
if (options.output) {
|
|
246
246
|
filename = await getFilename(options.output, options);
|
|
@@ -258,7 +258,11 @@ async function capturePage(options) {
|
|
|
258
258
|
if (directoryName !== ".") {
|
|
259
259
|
await mkdir(directoryName, { recursive: true });
|
|
260
260
|
}
|
|
261
|
-
|
|
261
|
+
if (pageData.content instanceof Uint8Array) {
|
|
262
|
+
await writeFile(filename, pageData.content);
|
|
263
|
+
} else {
|
|
264
|
+
await writeTextFile(filename, pageData.content);
|
|
265
|
+
}
|
|
262
266
|
}
|
|
263
267
|
return pageData;
|
|
264
268
|
} catch (error) {
|
package/single-file-launcher.js
CHANGED
|
@@ -27,7 +27,7 @@ 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 };
|
|
@@ -83,6 +83,7 @@ async function run() {
|
|
|
83
83
|
await singlefile.finish();
|
|
84
84
|
} catch (error) {
|
|
85
85
|
console.error(error.message || error); // eslint-disable-line no-console
|
|
86
|
+
exit(-1);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|