@sovovs/bycli 2.1.20 → 2.1.21
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { constants } from 'node:fs';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { copyFile, link, mkdir, stat, unlink } from 'node:fs/promises';
|
|
4
|
-
import {
|
|
4
|
+
import { extname, resolve } from 'node:path';
|
|
5
5
|
import { CommandExecutionError, TimeoutError } from '@sovovs/bycli/errors';
|
|
6
6
|
|
|
7
7
|
function commandError(message) {
|
|
@@ -28,12 +28,11 @@ function trustedDownloadLink(link, detailUrl) {
|
|
|
28
28
|
&& candidate.searchParams.get('download') === '1';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function safeFilename(
|
|
32
|
-
const
|
|
33
|
-
const clean = value => basename(value)
|
|
31
|
+
function safeFilename(title) {
|
|
32
|
+
const clean = String(title ?? '')
|
|
34
33
|
.replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_')
|
|
35
34
|
.trim();
|
|
36
|
-
let name = clean
|
|
35
|
+
let name = clean || 'publish-data';
|
|
37
36
|
if (extname(name).toLowerCase() !== '.xls') name += '.xls';
|
|
38
37
|
return name;
|
|
39
38
|
}
|
|
@@ -151,7 +150,7 @@ export async function downloadPublishData(page, options) {
|
|
|
151
150
|
const target = await publishExclusively(
|
|
152
151
|
downloaded.filename,
|
|
153
152
|
outputDir,
|
|
154
|
-
safeFilename(
|
|
153
|
+
safeFilename(options.title),
|
|
155
154
|
);
|
|
156
155
|
try {
|
|
157
156
|
await unlink(downloaded.filename);
|