xshell 1.2.32 → 1.2.33
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/file.d.ts +3 -2
- package/file.js +16 -1
- package/package.json +1 -1
- package/path.d.ts +2 -2
package/file.d.ts
CHANGED
|
@@ -120,9 +120,10 @@ export declare function fdelete(fp: string, { print }?: {
|
|
|
120
120
|
red?: boolean;
|
|
121
121
|
}): Promise<boolean>;
|
|
122
122
|
/** 清空文件夹中的内容,实际为删除该文件夹后新建 */
|
|
123
|
-
export declare function fdclear(fpd: string, { print }?: {
|
|
123
|
+
export declare function fdclear(fpd: string, { print, permission }?: {
|
|
124
124
|
print?: boolean;
|
|
125
|
-
|
|
125
|
+
permission?: boolean;
|
|
126
|
+
}): Promise<string>;
|
|
126
127
|
export interface FCopyOptions {
|
|
127
128
|
print?: boolean;
|
|
128
129
|
overwrite?: boolean;
|
package/file.js
CHANGED
|
@@ -288,11 +288,26 @@ export async function fdelete(fp, { print = true } = {}) {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
/** 清空文件夹中的内容,实际为删除该文件夹后新建 */
|
|
291
|
-
export async function fdclear(fpd, { print = true } = {}) {
|
|
291
|
+
export async function fdclear(fpd, { print = true, permission = false } = {}) {
|
|
292
|
+
let stat;
|
|
293
|
+
if (permission && process.platform !== 'win32')
|
|
294
|
+
stat = await fstat(fpd);
|
|
292
295
|
await fdelete(fpd, noprint);
|
|
293
296
|
await fmkdir(fpd, noprint);
|
|
297
|
+
if (stat) {
|
|
298
|
+
let handle;
|
|
299
|
+
try {
|
|
300
|
+
handle = await fopen(fpd, 'w');
|
|
301
|
+
await handle.chown(Number(stat.uid), Number(stat.gid));
|
|
302
|
+
await handle.chmod(Number(stat.mode));
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
handle?.close();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
294
308
|
if (print)
|
|
295
309
|
console.log(`清空了文件夹 ${fpd}`);
|
|
310
|
+
return fpd;
|
|
296
311
|
}
|
|
297
312
|
/** 复制文件或文件夹
|
|
298
313
|
会在因不存在父文件夹导致复制失败时,自动创建父文件夹,并再次尝试复制
|
package/package.json
CHANGED
package/path.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare function extname(path: string): string;
|
|
|
54
54
|
/** `/` */
|
|
55
55
|
export declare const sep = "/";
|
|
56
56
|
/** The platform-specific file delimiter. ';' or ':'. */
|
|
57
|
-
export declare const delimiter: "
|
|
57
|
+
export declare const delimiter: ";" | ":";
|
|
58
58
|
/** Returns an object from a path string - the opposite of format().
|
|
59
59
|
@param path path to evaluate.
|
|
60
60
|
@throws {TypeError} if `path` is not a string. */
|
|
@@ -81,7 +81,7 @@ export declare let path: {
|
|
|
81
81
|
basename: typeof basename;
|
|
82
82
|
extname: typeof extname;
|
|
83
83
|
sep: string;
|
|
84
|
-
delimiter: "
|
|
84
|
+
delimiter: ";" | ":";
|
|
85
85
|
parse: typeof parse;
|
|
86
86
|
format: typeof format;
|
|
87
87
|
toNamespacedPath: typeof toNamespacedPath;
|