xjs-node 3.1.0 → 3.2.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
|
@@ -29,7 +29,11 @@ export declare namespace UFile {
|
|
|
29
29
|
function readAsJson<T = any>(p: MaybeArray<string>, d?: any, encoding?: BufferEncoding): Promise<T>;
|
|
30
30
|
function cp(from: MaybeArray<string>, to: MaybeArray<string>): Promise<void>;
|
|
31
31
|
function mv(from: MaybeArray<string>, to: MaybeArray<string>): Promise<void>;
|
|
32
|
-
function ls(p: MaybeArray<string
|
|
32
|
+
function ls(p: MaybeArray<string>, withStats: true): {
|
|
33
|
+
fname: string;
|
|
34
|
+
stats: fs.Stats;
|
|
35
|
+
}[];
|
|
36
|
+
function ls(p: MaybeArray<string>, withStats?: boolean): string[];
|
|
33
37
|
/**
|
|
34
38
|
* check availability to export a file with specified directory and file name.
|
|
35
39
|
* if it doesn't, this retries to check after appending incremental number to the filename excluding an extension (e.g. `aaa_1.txt`).
|
package/build/func/u-file.js
CHANGED
|
@@ -120,11 +120,12 @@ var UFile;
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
UFile.mv = mv;
|
|
123
|
-
function ls(p) {
|
|
123
|
+
function ls(p, withStats) {
|
|
124
124
|
const pt = (0, u_1.joinPath)(p);
|
|
125
125
|
if (!pt || !fs.statSync(pt).isDirectory())
|
|
126
126
|
throw new xjs_common_1.XjsErr(s_errCode, "Specified path for ls is not directory.");
|
|
127
|
-
|
|
127
|
+
const fnames = fs.readdirSync(pt);
|
|
128
|
+
return withStats ? fnames.map(f => ({ fname: f, stats: status([pt, f]) })) : fnames;
|
|
128
129
|
}
|
|
129
130
|
UFile.ls = ls;
|
|
130
131
|
/**
|
|
@@ -224,7 +224,7 @@ class HttpResolverContext {
|
|
|
224
224
|
const stream = fs.createWriteStream(dest);
|
|
225
225
|
res.pipe(stream);
|
|
226
226
|
stream.on("finish", () => stream.close());
|
|
227
|
-
stream.on("close", () => resolve({ headers: res.headers }));
|
|
227
|
+
stream.on("close", () => resolve({ headers: res.headers, status: res.statusCode }));
|
|
228
228
|
stream.on("error", e => this.handleError(reject, e, "an error occurred on donwloading stream."));
|
|
229
229
|
return;
|
|
230
230
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xjs-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "library modules for nodejs + typescript that bundled general-purpose implementations.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^24.2.1",
|
|
35
35
|
"tsx": "^4.20.3",
|
|
36
|
-
"typescript": "^5.8.3"
|
|
36
|
+
"typescript": "^5.8.3",
|
|
37
|
+
"xjs-test": "^1.1.0"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
40
|
"xjs-common": "^13.6.1"
|