namirasoft-core 1.3.6 → 1.3.8
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/dist/FileOperation.d.ts +1 -1
- package/dist/FileOperation.js +14 -10
- package/dist/FileOperation.js.map +1 -1
- package/package.json +1 -1
- package/src/FileOperation.ts +13 -9
package/dist/FileOperation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare class FileOperation {
|
|
2
2
|
static findUp(fileName: string): string[];
|
|
3
|
-
static
|
|
3
|
+
static foreach(base: string, handler: (base: string, sub: string, name: string, full: string, isFolder: boolean) => Promise<boolean | void>, folders?: boolean, files?: boolean): Promise<void>;
|
|
4
4
|
}
|
package/dist/FileOperation.js
CHANGED
|
@@ -35,22 +35,26 @@ class FileOperation {
|
|
|
35
35
|
searchRecursively(currentDir);
|
|
36
36
|
return foundFilePaths;
|
|
37
37
|
}
|
|
38
|
-
static
|
|
38
|
+
static foreach(base, handler, folders = true, files = true) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
function recursive(base, sub) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
let
|
|
43
|
-
for (let
|
|
44
|
-
let
|
|
45
|
-
let
|
|
46
|
-
if (fs.statSync(
|
|
47
|
-
if (folders)
|
|
48
|
-
yield handler(base, sub,
|
|
49
|
-
|
|
42
|
+
let names = fs.readdirSync(path.join(base, sub));
|
|
43
|
+
for (let name of names) {
|
|
44
|
+
let newSub = path.join(sub, name);
|
|
45
|
+
let full = path.join(base, newSub);
|
|
46
|
+
if (fs.statSync(full).isDirectory()) {
|
|
47
|
+
if (folders) {
|
|
48
|
+
let stop = yield handler(base, sub, name, full, true);
|
|
49
|
+
if (stop)
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
;
|
|
53
|
+
yield recursive(base, newSub);
|
|
50
54
|
}
|
|
51
55
|
else {
|
|
52
56
|
if (files)
|
|
53
|
-
yield handler(base, sub,
|
|
57
|
+
yield handler(base, sub, name, full, false);
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileOperation.js","sourceRoot":"","sources":["../src/FileOperation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAI,EAAO,CAAC;AACZ,IAAI,IAAS,CAAC;AACd,IAAI,OAAO,MAAM,KAAK,WAAW,EACjC;IACI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1B;AACD,MAAa,aAAa;IAEtB,MAAM,CAAC,MAAM,CAAC,QAAgB;QAE1B,IAAI,UAAU,GAAW,SAAS,CAAC;QACnC,MAAM,OAAO,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;QACtC,MAAM,cAAc,GAAa,EAAE,CAAC;QACpC,SAAS,iBAAiB,CAAC,GAAW;YAElC,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACxB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;YAClD,IAAI,OAAO,KAAK,GAAG;gBACf,OAAO;YACX,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,OAAO,IAAI,GAAG;gBACd,OAAO;YACX,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC9B,OAAO,cAAc,CAAC;IAC1B,CAAC;IACD,MAAM,CAAO,
|
|
1
|
+
{"version":3,"file":"FileOperation.js","sourceRoot":"","sources":["../src/FileOperation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAI,EA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AAC,CAAA;wBACjC,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;wBACnC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EACnC;4BACI,IAAI,OAAO,EACX;gCACI,IAAI,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gCACtD,IAAI,IAAI;oCACJ,SAAS;6BAChB;4BAAA,CAAC;4BACF,MAAM,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;yBACjC;6BAED;4BACI,IAAI,KAAK;gCACL,MAAM,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;yBACnD;qBACJ;gBACL,CAAC;aAAA;YACD,MAAM,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,CAAC;KAAA;CACJ;AAlDD,sCAkDC"}
|
package/package.json
CHANGED
package/src/FileOperation.ts
CHANGED
|
@@ -27,25 +27,29 @@ export class FileOperation
|
|
|
27
27
|
searchRecursively(currentDir);
|
|
28
28
|
return foundFilePaths;
|
|
29
29
|
}
|
|
30
|
-
static async
|
|
30
|
+
static async foreach(base: string, handler: (base: string, sub: string, name: string, full: string, isFolder: boolean) => Promise<boolean | void>, folders: boolean = true, files: boolean = true)
|
|
31
31
|
{
|
|
32
32
|
async function recursive(base: string, sub: string)
|
|
33
33
|
{
|
|
34
|
-
let
|
|
35
|
-
for (let
|
|
34
|
+
let names = fs.readdirSync(path.join(base, sub));
|
|
35
|
+
for (let name of names)
|
|
36
36
|
{
|
|
37
|
-
let
|
|
38
|
-
let
|
|
39
|
-
if (fs.statSync(
|
|
37
|
+
let newSub = path.join(sub, name)
|
|
38
|
+
let full = path.join(base, newSub);
|
|
39
|
+
if (fs.statSync(full).isDirectory())
|
|
40
40
|
{
|
|
41
41
|
if (folders)
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
{
|
|
43
|
+
let stop = await handler(base, sub, name, full, true);
|
|
44
|
+
if (stop)
|
|
45
|
+
continue;
|
|
46
|
+
};
|
|
47
|
+
await recursive(base, newSub);
|
|
44
48
|
}
|
|
45
49
|
else
|
|
46
50
|
{
|
|
47
51
|
if (files)
|
|
48
|
-
await handler(base, sub,
|
|
52
|
+
await handler(base, sub, name, full, false);
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
}
|