xjs-node 2.2.0 → 2.3.0
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/build/func/u-file.d.ts
CHANGED
|
@@ -36,10 +36,9 @@ export declare namespace UFile {
|
|
|
36
36
|
function ls(p: MaybeArray<string>): string[];
|
|
37
37
|
/**
|
|
38
38
|
* check availability to export a file with specified directory and file name.
|
|
39
|
-
* if it doesn't,
|
|
39
|
+
* if it doesn't, this retries to check after appending incremental number to the filename excluding an extension (e.g. `aaa_1.txt`).
|
|
40
40
|
* @param dir destination directory path.
|
|
41
41
|
* @param fname file name wanna export to.
|
|
42
|
-
* @returns exportable file path.
|
|
43
42
|
*/
|
|
44
43
|
function reserveFilePath(dir: MaybeArray<string>, fname: string): string;
|
|
45
44
|
/**
|
package/build/func/u-file.js
CHANGED
|
@@ -116,10 +116,9 @@ var UFile;
|
|
|
116
116
|
UFile.ls = ls;
|
|
117
117
|
/**
|
|
118
118
|
* check availability to export a file with specified directory and file name.
|
|
119
|
-
* if it doesn't,
|
|
119
|
+
* if it doesn't, this retries to check after appending incremental number to the filename excluding an extension (e.g. `aaa_1.txt`).
|
|
120
120
|
* @param dir destination directory path.
|
|
121
121
|
* @param fname file name wanna export to.
|
|
122
|
-
* @returns exportable file path.
|
|
123
122
|
*/
|
|
124
123
|
function reserveFilePath(dir, fname) {
|
|
125
124
|
const pt = (0, u_1.joinPath)(dir);
|
|
@@ -128,8 +127,10 @@ var UFile;
|
|
|
128
127
|
if (!fname || fname.match(/[\\/:*?"<>|]/))
|
|
129
128
|
throw new xjs_common_1.XjsErr(s_errCode, "Specified filename is invalid due to empty or including disallowed characters.");
|
|
130
129
|
let dest = (0, u_1.joinPath)(pt, fname), i = 1;
|
|
131
|
-
while (fs.existsSync(dest))
|
|
132
|
-
|
|
130
|
+
while (fs.existsSync(dest)) {
|
|
131
|
+
const ext = fname.match(/^(.+)(\.[^\.]+)$/);
|
|
132
|
+
dest = (0, u_1.joinPath)(pt, `${ext ? ext[1] : fname}_${i++}${ext ? ext[2] : ""}`);
|
|
133
|
+
}
|
|
133
134
|
return dest;
|
|
134
135
|
}
|
|
135
136
|
UFile.reserveFilePath = reserveFilePath;
|
|
@@ -14,15 +14,15 @@ export interface ClientOption {
|
|
|
14
14
|
/**
|
|
15
15
|
* chrome major version refered when construct an user agent.
|
|
16
16
|
*/
|
|
17
|
-
cmv
|
|
17
|
+
cmv?: number;
|
|
18
18
|
/**
|
|
19
19
|
* custom logger. default is `console`.
|
|
20
20
|
*/
|
|
21
|
-
logger
|
|
21
|
+
logger?: Loggable;
|
|
22
22
|
/**
|
|
23
23
|
* verbosity of logging.
|
|
24
24
|
*/
|
|
25
|
-
logLevel
|
|
25
|
+
logLevel?: LogLevel;
|
|
26
26
|
}
|
|
27
27
|
export interface RequestOption {
|
|
28
28
|
headers?: OutgoingHttpHeaders;
|