@pristine-ts/file 0.0.229
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/LICENSE +201 -0
- package/dist/lib/cjs/enums/directory-list-result.enum.js +9 -0
- package/dist/lib/cjs/enums/directory-list-result.enum.js.map +1 -0
- package/dist/lib/cjs/enums/enums.js +20 -0
- package/dist/lib/cjs/enums/enums.js.map +1 -0
- package/dist/lib/cjs/enums/match-type.enum.js +10 -0
- package/dist/lib/cjs/enums/match-type.enum.js.map +1 -0
- package/dist/lib/cjs/enums/types.enum.js +10 -0
- package/dist/lib/cjs/enums/types.enum.js.map +1 -0
- package/dist/lib/cjs/file.module.js +30 -0
- package/dist/lib/cjs/file.module.js.map +1 -0
- package/dist/lib/cjs/file.module.keyname.js +5 -0
- package/dist/lib/cjs/file.module.keyname.js.map +1 -0
- package/dist/lib/cjs/interfaces/file-info.interface.js +3 -0
- package/dist/lib/cjs/interfaces/file-info.interface.js.map +1 -0
- package/dist/lib/cjs/managers/directory.manager.js +179 -0
- package/dist/lib/cjs/managers/directory.manager.js.map +1 -0
- package/dist/lib/cjs/managers/managers.js +18 -0
- package/dist/lib/cjs/managers/managers.js.map +1 -0
- package/dist/lib/cjs/options/directory-list.options.js +3 -0
- package/dist/lib/cjs/options/directory-list.options.js.map +1 -0
- package/dist/lib/cjs/options/options.js +18 -0
- package/dist/lib/cjs/options/options.js.map +1 -0
- package/dist/lib/esm/enums/directory-list-result.enum.js +6 -0
- package/dist/lib/esm/enums/directory-list-result.enum.js.map +1 -0
- package/dist/lib/esm/enums/enums.js +4 -0
- package/dist/lib/esm/enums/enums.js.map +1 -0
- package/dist/lib/esm/enums/match-type.enum.js +7 -0
- package/dist/lib/esm/enums/match-type.enum.js.map +1 -0
- package/dist/lib/esm/enums/types.enum.js +7 -0
- package/dist/lib/esm/enums/types.enum.js.map +1 -0
- package/dist/lib/esm/file.module.js +13 -0
- package/dist/lib/esm/file.module.js.map +1 -0
- package/dist/lib/esm/file.module.keyname.js +2 -0
- package/dist/lib/esm/file.module.keyname.js.map +1 -0
- package/dist/lib/esm/interfaces/file-info.interface.js +2 -0
- package/dist/lib/esm/interfaces/file-info.interface.js.map +1 -0
- package/dist/lib/esm/managers/directory.manager.js +173 -0
- package/dist/lib/esm/managers/directory.manager.js.map +1 -0
- package/dist/lib/esm/managers/managers.js +2 -0
- package/dist/lib/esm/managers/managers.js.map +1 -0
- package/dist/lib/esm/options/directory-list.options.js +2 -0
- package/dist/lib/esm/options/directory-list.options.js.map +1 -0
- package/dist/lib/esm/options/options.js +2 -0
- package/dist/lib/esm/options/options.js.map +1 -0
- package/dist/types/enums/directory-list-result.enum.d.ts +4 -0
- package/dist/types/enums/enums.d.ts +3 -0
- package/dist/types/enums/match-type.enum.d.ts +5 -0
- package/dist/types/enums/types.enum.d.ts +5 -0
- package/dist/types/file.module.d.ts +5 -0
- package/dist/types/file.module.keyname.d.ts +1 -0
- package/dist/types/interfaces/file-info.interface.d.ts +7 -0
- package/dist/types/managers/directory.manager.d.ts +16 -0
- package/dist/types/managers/managers.d.ts +1 -0
- package/dist/types/options/directory-list.options.d.ts +67 -0
- package/dist/types/options/options.d.ts +1 -0
- package/package.json +60 -0
- package/readme.md +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DirectoryListResultEnum = void 0;
|
|
4
|
+
var DirectoryListResultEnum;
|
|
5
|
+
(function (DirectoryListResultEnum) {
|
|
6
|
+
DirectoryListResultEnum["FilePath"] = "FILE_PATH";
|
|
7
|
+
DirectoryListResultEnum["FileInfoObject"] = "FILE_INFO_OBJECT";
|
|
8
|
+
})(DirectoryListResultEnum = exports.DirectoryListResultEnum || (exports.DirectoryListResultEnum = {}));
|
|
9
|
+
//# sourceMappingURL=directory-list-result.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-list-result.enum.js","sourceRoot":"","sources":["../../../../src/enums/directory-list-result.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IAC/B,iDAAsB,CAAA;IACtB,8DAAmC,CAAA;AACvC,CAAC,EAHW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAGlC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./directory-list-result.enum"), exports);
|
|
18
|
+
__exportStar(require("./match-type.enum"), exports);
|
|
19
|
+
__exportStar(require("./types.enum"), exports);
|
|
20
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,oDAAkC;AAClC,+CAA6B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MatchTypeEnum = void 0;
|
|
4
|
+
var MatchTypeEnum;
|
|
5
|
+
(function (MatchTypeEnum) {
|
|
6
|
+
MatchTypeEnum["Base"] = "BASE";
|
|
7
|
+
MatchTypeEnum["Extension"] = "EXT";
|
|
8
|
+
MatchTypeEnum["Filename"] = "FILE_NAME";
|
|
9
|
+
})(MatchTypeEnum = exports.MatchTypeEnum || (exports.MatchTypeEnum = {}));
|
|
10
|
+
//# sourceMappingURL=match-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/match-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,uCAAsB,CAAA;AAC1B,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypesEnum = void 0;
|
|
4
|
+
var TypesEnum;
|
|
5
|
+
(function (TypesEnum) {
|
|
6
|
+
TypesEnum["File"] = "FILE";
|
|
7
|
+
TypesEnum["Directory"] = "DIRECTORY";
|
|
8
|
+
TypesEnum["ALL"] = "ALL";
|
|
9
|
+
})(TypesEnum = exports.TypesEnum || (exports.TypesEnum = {}));
|
|
10
|
+
//# sourceMappingURL=types.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.enum.js","sourceRoot":"","sources":["../../../../src/enums/types.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,0BAAa,CAAA;IACb,oCAAuB,CAAA;IACvB,wBAAW,CAAA;AACf,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FileModule = void 0;
|
|
18
|
+
const common_1 = require("@pristine-ts/common");
|
|
19
|
+
const file_module_keyname_1 = require("./file.module.keyname");
|
|
20
|
+
__exportStar(require("./enums/enums"), exports);
|
|
21
|
+
__exportStar(require("./managers/managers"), exports);
|
|
22
|
+
__exportStar(require("./options/options"), exports);
|
|
23
|
+
exports.FileModule = {
|
|
24
|
+
keyname: file_module_keyname_1.FileModuleKeyname,
|
|
25
|
+
configurationDefinitions: [],
|
|
26
|
+
importModules: [
|
|
27
|
+
common_1.CommonModule,
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=file.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/file.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAkE;AAClE,+DAAwD;AAExD,gDAA8B;AAC9B,sDAAoC;AACpC,oDAAkC;AAErB,QAAA,UAAU,GAAoB;IACvC,OAAO,EAAE,uCAAiB;IAC1B,wBAAwB,EAAE,EACzB;IACD,aAAa,EAAE;QACX,qBAAY;KACf;CACJ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.module.keyname.js","sourceRoot":"","sources":["../../../src/file.module.keyname.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAW,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-info.interface.js","sourceRoot":"","sources":["../../../../src/interfaces/file-info.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.DirectoryManager = void 0;
|
|
22
|
+
require("reflect-metadata");
|
|
23
|
+
const tsyringe_1 = require("tsyringe");
|
|
24
|
+
const match_type_enum_1 = require("../enums/match-type.enum");
|
|
25
|
+
const types_enum_1 = require("../enums/types.enum");
|
|
26
|
+
const directory_list_result_enum_1 = require("../enums/directory-list-result.enum");
|
|
27
|
+
const fs_1 = require("fs");
|
|
28
|
+
const path_1 = __importDefault(require("path"));
|
|
29
|
+
let DirectoryManager = class DirectoryManager {
|
|
30
|
+
listRecursively(dir, options) {
|
|
31
|
+
var _a;
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
// collect sub-directories for possible recursion
|
|
34
|
+
const dirs = [];
|
|
35
|
+
const files = yield fs_1.promises.readdir(dir, { withFileTypes: true });
|
|
36
|
+
for (const dirEnt of files) {
|
|
37
|
+
const filename = dirEnt.name;
|
|
38
|
+
const fullPath = path_1.default.join(dir, filename);
|
|
39
|
+
const ext = path_1.default.extname(filename).slice(1); // file extension without leading "."
|
|
40
|
+
let basename = filename;
|
|
41
|
+
if (ext.length) {
|
|
42
|
+
basename = filename.slice(0, -(ext.length + 1)); // get part without the extension
|
|
43
|
+
}
|
|
44
|
+
// put all this in an object for later use
|
|
45
|
+
const obj = { filename, basename, extension: ext, fullPath, type: "" };
|
|
46
|
+
// get type of entry
|
|
47
|
+
let type = "<unknown>";
|
|
48
|
+
let include = false;
|
|
49
|
+
if (dirEnt.isFile()) {
|
|
50
|
+
type = "file";
|
|
51
|
+
include = options.types === types_enum_1.TypesEnum.File || options.types === types_enum_1.TypesEnum.ALL;
|
|
52
|
+
}
|
|
53
|
+
else if (dirEnt.isDirectory()) {
|
|
54
|
+
type = "dir";
|
|
55
|
+
include = options.types === types_enum_1.TypesEnum.Directory || options.types === types_enum_1.TypesEnum.ALL;
|
|
56
|
+
dirs.push(obj); // save dir for recursion option
|
|
57
|
+
}
|
|
58
|
+
obj.type = type;
|
|
59
|
+
if (!include) {
|
|
60
|
+
continue; // skip further processing for this file/dir
|
|
61
|
+
}
|
|
62
|
+
// see if we should skip top level files
|
|
63
|
+
if (options.skipTopLevelFiles && type === "file") {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// if doing matching
|
|
67
|
+
if (options.match) {
|
|
68
|
+
let target;
|
|
69
|
+
if (options.matchType === match_type_enum_1.MatchTypeEnum.Extension) {
|
|
70
|
+
target = ext;
|
|
71
|
+
}
|
|
72
|
+
else if (options.matchType === match_type_enum_1.MatchTypeEnum.Base) {
|
|
73
|
+
target = basename;
|
|
74
|
+
}
|
|
75
|
+
else if (options.matchType === match_type_enum_1.MatchTypeEnum.Filename) {
|
|
76
|
+
target = filename;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw new Error(`When trying to list the files, options.matchType contains invalid value "${options.matchType}", should be "MatchTypeEnum.Extension", "MatchTypeEnum.Base" or "MatchTypeEnum.Filename"`);
|
|
80
|
+
}
|
|
81
|
+
switch (typeof options.match) {
|
|
82
|
+
case "string":
|
|
83
|
+
// require exact match to target, skip if no match
|
|
84
|
+
if (options.matchCaseInsensitive) {
|
|
85
|
+
target = target.toLowerCase();
|
|
86
|
+
}
|
|
87
|
+
if (options.match !== target)
|
|
88
|
+
continue;
|
|
89
|
+
break;
|
|
90
|
+
case "object":
|
|
91
|
+
// compare with regex, skip if no match
|
|
92
|
+
if (!options.match.test(target))
|
|
93
|
+
continue;
|
|
94
|
+
break;
|
|
95
|
+
case "function":
|
|
96
|
+
// custom filter function, if doesn't return true, skip this item
|
|
97
|
+
if (!(yield options.match(obj)))
|
|
98
|
+
continue;
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
throw new TypeError(`When trying to list the files, options.match contains invalid value, should be a string, regex or function`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (Array.isArray(options.results) === false || options.results === undefined) {
|
|
105
|
+
options.results = [];
|
|
106
|
+
}
|
|
107
|
+
// passed all the tests, add the summary object to the results
|
|
108
|
+
if (options.resultType === directory_list_result_enum_1.DirectoryListResultEnum.FileInfoObject) {
|
|
109
|
+
options.results.push(obj);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
options.results.push(fullPath);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (options.recurse) {
|
|
116
|
+
options.skipTopLevelFiles = false; // turn this off for recursion
|
|
117
|
+
for (const d of dirs) {
|
|
118
|
+
let include = true;
|
|
119
|
+
if (typeof options.recurse === "function") {
|
|
120
|
+
include = yield options.recurse(d);
|
|
121
|
+
}
|
|
122
|
+
if (include) {
|
|
123
|
+
yield this.listRecursively(d.fullPath, options);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return (_a = options.results) !== null && _a !== void 0 ? _a : [];
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* If you just call list(someDir) with no options, it just gets you
|
|
132
|
+
* and array of all the full path filenames in an array
|
|
133
|
+
* You add match options to limit what it returns
|
|
134
|
+
* You add the type option to limit it to only files or directories or specify you want both
|
|
135
|
+
*
|
|
136
|
+
* @param directory
|
|
137
|
+
* @param options
|
|
138
|
+
*/
|
|
139
|
+
list(directory, options) {
|
|
140
|
+
// initialization here that does not need to be done on recursive calls
|
|
141
|
+
// make copy of options object and initialize defaults
|
|
142
|
+
// we put results array in the options so it can be passed into the recursive calls and
|
|
143
|
+
// they can just add to the same array rather than having to merge arrays
|
|
144
|
+
const defaults = {
|
|
145
|
+
matchType: match_type_enum_1.MatchTypeEnum.Extension,
|
|
146
|
+
types: types_enum_1.TypesEnum.File,
|
|
147
|
+
resultType: directory_list_result_enum_1.DirectoryListResultEnum.FilePath,
|
|
148
|
+
results: [],
|
|
149
|
+
};
|
|
150
|
+
if (options !== undefined) {
|
|
151
|
+
if (typeof options.match === "string") {
|
|
152
|
+
defaults.matchCaseInsensitive = true;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (options.matchCaseInsensitive) {
|
|
156
|
+
throw new TypeError("When trying to list the files, options.matchCaseInsensitive can only be specified when options.match is a string");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
options = Object.assign(defaults, options);
|
|
161
|
+
if (typeof options.match === "object" && !(options.match instanceof RegExp)) {
|
|
162
|
+
throw new TypeError("If options.match is an object it must be a RegExp object");
|
|
163
|
+
}
|
|
164
|
+
if (options.match && typeof options.match === "string" && options.matchCaseInsensitive) {
|
|
165
|
+
options.match = options.match.toLowerCase();
|
|
166
|
+
}
|
|
167
|
+
// force dir to be absolute path
|
|
168
|
+
let src = directory;
|
|
169
|
+
if (!path_1.default.isAbsolute(src)) {
|
|
170
|
+
src = path_1.default.resolve(src);
|
|
171
|
+
}
|
|
172
|
+
return this.listRecursively(src, options);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
DirectoryManager = __decorate([
|
|
176
|
+
(0, tsyringe_1.injectable)()
|
|
177
|
+
], DirectoryManager);
|
|
178
|
+
exports.DirectoryManager = DirectoryManager;
|
|
179
|
+
//# sourceMappingURL=directory.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.manager.js","sourceRoot":"","sources":["../../../../src/managers/directory.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;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AC,CAAC;IAC9C,CAAC;CACJ,CAAA;AAvJY,gBAAgB;IAD5B,IAAA,qBAAU,GAAE;GACA,gBAAgB,CAuJ5B;AAvJY,4CAAgB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./directory.manager"), exports);
|
|
18
|
+
//# sourceMappingURL=managers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managers.js","sourceRoot":"","sources":["../../../../src/managers/managers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-list.options.js","sourceRoot":"","sources":["../../../../src/options/directory-list.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./directory-list.options"), exports);
|
|
18
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/options/options.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var DirectoryListResultEnum;
|
|
2
|
+
(function (DirectoryListResultEnum) {
|
|
3
|
+
DirectoryListResultEnum["FilePath"] = "FILE_PATH";
|
|
4
|
+
DirectoryListResultEnum["FileInfoObject"] = "FILE_INFO_OBJECT";
|
|
5
|
+
})(DirectoryListResultEnum || (DirectoryListResultEnum = {}));
|
|
6
|
+
//# sourceMappingURL=directory-list-result.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-list-result.enum.js","sourceRoot":"","sources":["../../../../src/enums/directory-list-result.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IAC/B,iDAAsB,CAAA;IACtB,8DAAmC,CAAA;AACvC,CAAC,EAHW,uBAAuB,KAAvB,uBAAuB,QAGlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-type.enum.js","sourceRoot":"","sources":["../../../../src/enums/match-type.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,uCAAsB,CAAA;AAC1B,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.enum.js","sourceRoot":"","sources":["../../../../src/enums/types.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,0BAAa,CAAA;IACb,oCAAuB,CAAA;IACvB,wBAAW,CAAA;AACf,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommonModule } from "@pristine-ts/common";
|
|
2
|
+
import { FileModuleKeyname } from "./file.module.keyname";
|
|
3
|
+
export * from "./enums/enums";
|
|
4
|
+
export * from "./managers/managers";
|
|
5
|
+
export * from "./options/options";
|
|
6
|
+
export const FileModule = {
|
|
7
|
+
keyname: FileModuleKeyname,
|
|
8
|
+
configurationDefinitions: [],
|
|
9
|
+
importModules: [
|
|
10
|
+
CommonModule,
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=file.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.module.js","sourceRoot":"","sources":["../../../src/file.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAExD,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAoB;IACvC,OAAO,EAAE,iBAAiB;IAC1B,wBAAwB,EAAE,EACzB;IACD,aAAa,EAAE;QACX,YAAY;KACf;CACJ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.module.keyname.js","sourceRoot":"","sources":["../../../src/file.module.keyname.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAW,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-info.interface.js","sourceRoot":"","sources":["../../../../src/interfaces/file-info.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
import "reflect-metadata";
|
|
17
|
+
import { injectable } from "tsyringe";
|
|
18
|
+
import { MatchTypeEnum } from "../enums/match-type.enum";
|
|
19
|
+
import { TypesEnum } from "../enums/types.enum";
|
|
20
|
+
import { DirectoryListResultEnum } from "../enums/directory-list-result.enum";
|
|
21
|
+
import { promises as fsp } from "fs";
|
|
22
|
+
import path from "path";
|
|
23
|
+
let DirectoryManager = class DirectoryManager {
|
|
24
|
+
listRecursively(dir, options) {
|
|
25
|
+
var _a;
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
// collect sub-directories for possible recursion
|
|
28
|
+
const dirs = [];
|
|
29
|
+
const files = yield fsp.readdir(dir, { withFileTypes: true });
|
|
30
|
+
for (const dirEnt of files) {
|
|
31
|
+
const filename = dirEnt.name;
|
|
32
|
+
const fullPath = path.join(dir, filename);
|
|
33
|
+
const ext = path.extname(filename).slice(1); // file extension without leading "."
|
|
34
|
+
let basename = filename;
|
|
35
|
+
if (ext.length) {
|
|
36
|
+
basename = filename.slice(0, -(ext.length + 1)); // get part without the extension
|
|
37
|
+
}
|
|
38
|
+
// put all this in an object for later use
|
|
39
|
+
const obj = { filename, basename, extension: ext, fullPath, type: "" };
|
|
40
|
+
// get type of entry
|
|
41
|
+
let type = "<unknown>";
|
|
42
|
+
let include = false;
|
|
43
|
+
if (dirEnt.isFile()) {
|
|
44
|
+
type = "file";
|
|
45
|
+
include = options.types === TypesEnum.File || options.types === TypesEnum.ALL;
|
|
46
|
+
}
|
|
47
|
+
else if (dirEnt.isDirectory()) {
|
|
48
|
+
type = "dir";
|
|
49
|
+
include = options.types === TypesEnum.Directory || options.types === TypesEnum.ALL;
|
|
50
|
+
dirs.push(obj); // save dir for recursion option
|
|
51
|
+
}
|
|
52
|
+
obj.type = type;
|
|
53
|
+
if (!include) {
|
|
54
|
+
continue; // skip further processing for this file/dir
|
|
55
|
+
}
|
|
56
|
+
// see if we should skip top level files
|
|
57
|
+
if (options.skipTopLevelFiles && type === "file") {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
// if doing matching
|
|
61
|
+
if (options.match) {
|
|
62
|
+
let target;
|
|
63
|
+
if (options.matchType === MatchTypeEnum.Extension) {
|
|
64
|
+
target = ext;
|
|
65
|
+
}
|
|
66
|
+
else if (options.matchType === MatchTypeEnum.Base) {
|
|
67
|
+
target = basename;
|
|
68
|
+
}
|
|
69
|
+
else if (options.matchType === MatchTypeEnum.Filename) {
|
|
70
|
+
target = filename;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new Error(`When trying to list the files, options.matchType contains invalid value "${options.matchType}", should be "MatchTypeEnum.Extension", "MatchTypeEnum.Base" or "MatchTypeEnum.Filename"`);
|
|
74
|
+
}
|
|
75
|
+
switch (typeof options.match) {
|
|
76
|
+
case "string":
|
|
77
|
+
// require exact match to target, skip if no match
|
|
78
|
+
if (options.matchCaseInsensitive) {
|
|
79
|
+
target = target.toLowerCase();
|
|
80
|
+
}
|
|
81
|
+
if (options.match !== target)
|
|
82
|
+
continue;
|
|
83
|
+
break;
|
|
84
|
+
case "object":
|
|
85
|
+
// compare with regex, skip if no match
|
|
86
|
+
if (!options.match.test(target))
|
|
87
|
+
continue;
|
|
88
|
+
break;
|
|
89
|
+
case "function":
|
|
90
|
+
// custom filter function, if doesn't return true, skip this item
|
|
91
|
+
if (!(yield options.match(obj)))
|
|
92
|
+
continue;
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
throw new TypeError(`When trying to list the files, options.match contains invalid value, should be a string, regex or function`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(options.results) === false || options.results === undefined) {
|
|
99
|
+
options.results = [];
|
|
100
|
+
}
|
|
101
|
+
// passed all the tests, add the summary object to the results
|
|
102
|
+
if (options.resultType === DirectoryListResultEnum.FileInfoObject) {
|
|
103
|
+
options.results.push(obj);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
options.results.push(fullPath);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (options.recurse) {
|
|
110
|
+
options.skipTopLevelFiles = false; // turn this off for recursion
|
|
111
|
+
for (const d of dirs) {
|
|
112
|
+
let include = true;
|
|
113
|
+
if (typeof options.recurse === "function") {
|
|
114
|
+
include = yield options.recurse(d);
|
|
115
|
+
}
|
|
116
|
+
if (include) {
|
|
117
|
+
yield this.listRecursively(d.fullPath, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return (_a = options.results) !== null && _a !== void 0 ? _a : [];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* If you just call list(someDir) with no options, it just gets you
|
|
126
|
+
* and array of all the full path filenames in an array
|
|
127
|
+
* You add match options to limit what it returns
|
|
128
|
+
* You add the type option to limit it to only files or directories or specify you want both
|
|
129
|
+
*
|
|
130
|
+
* @param directory
|
|
131
|
+
* @param options
|
|
132
|
+
*/
|
|
133
|
+
list(directory, options) {
|
|
134
|
+
// initialization here that does not need to be done on recursive calls
|
|
135
|
+
// make copy of options object and initialize defaults
|
|
136
|
+
// we put results array in the options so it can be passed into the recursive calls and
|
|
137
|
+
// they can just add to the same array rather than having to merge arrays
|
|
138
|
+
const defaults = {
|
|
139
|
+
matchType: MatchTypeEnum.Extension,
|
|
140
|
+
types: TypesEnum.File,
|
|
141
|
+
resultType: DirectoryListResultEnum.FilePath,
|
|
142
|
+
results: [],
|
|
143
|
+
};
|
|
144
|
+
if (options !== undefined) {
|
|
145
|
+
if (typeof options.match === "string") {
|
|
146
|
+
defaults.matchCaseInsensitive = true;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
if (options.matchCaseInsensitive) {
|
|
150
|
+
throw new TypeError("When trying to list the files, options.matchCaseInsensitive can only be specified when options.match is a string");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
options = Object.assign(defaults, options);
|
|
155
|
+
if (typeof options.match === "object" && !(options.match instanceof RegExp)) {
|
|
156
|
+
throw new TypeError("If options.match is an object it must be a RegExp object");
|
|
157
|
+
}
|
|
158
|
+
if (options.match && typeof options.match === "string" && options.matchCaseInsensitive) {
|
|
159
|
+
options.match = options.match.toLowerCase();
|
|
160
|
+
}
|
|
161
|
+
// force dir to be absolute path
|
|
162
|
+
let src = directory;
|
|
163
|
+
if (!path.isAbsolute(src)) {
|
|
164
|
+
src = path.resolve(src);
|
|
165
|
+
}
|
|
166
|
+
return this.listRecursively(src, options);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
DirectoryManager = __decorate([
|
|
170
|
+
injectable()
|
|
171
|
+
], DirectoryManager);
|
|
172
|
+
export { DirectoryManager };
|
|
173
|
+
//# sourceMappingURL=directory.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.manager.js","sourceRoot":"","sources":["../../../../src/managers/directory.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,kBAAkB,CAAA;AACzB,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,uBAAuB,EAAC,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAC,QAAQ,IAAI,GAAG,EAAC,MAAM,IAAI,CAAC;AACnC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGjB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACX,eAAe,CAAC,GAAW,EAAE,OAA6B;;;YAEpE,iDAAiD;YACjD,MAAM,IAAI,GAAG,EAAE,CAAC;YAEhB,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAC,aAA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K,SAAS,EAAE;YACtB,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;gBACnC,QAAQ,CAAC,oBAAoB,GAAG,IAAI,CAAC;aACxC;iBAAM;gBACH,IAAI,OAAO,CAAC,oBAAoB,EAAE;oBAC9B,MAAM,IAAI,SAAS,CAAC,kHAAkH,CAAC,CAAC;iBAC3I;aACJ;SACJ;QAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAE3C,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,YAAY,MAAM,CAAC,EAAE;YACzE,MAAM,IAAI,SAAS,CAAC,0DAA0D,CAAC,CAAC;SACnF;QAED,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,oBAAoB,EAAE;YACpF,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;SAC/C;QAED,gCAAgC;QAChC,IAAI,GAAG,GAAG,SAAS,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACvB,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACJ,CAAA;AAvJY,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAuJ5B;SAvJY,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managers.js","sourceRoot":"","sources":["../../../../src/managers/managers.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-list.options.js","sourceRoot":"","sources":["../../../../src/options/directory-list.options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/options/options.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FileModuleKeyname: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { DirectoryListOptions } from "../options/directory-list.options";
|
|
3
|
+
import { FileInfoInterface } from "../interfaces/file-info.interface";
|
|
4
|
+
export declare class DirectoryManager {
|
|
5
|
+
private listRecursively;
|
|
6
|
+
/**
|
|
7
|
+
* If you just call list(someDir) with no options, it just gets you
|
|
8
|
+
* and array of all the full path filenames in an array
|
|
9
|
+
* You add match options to limit what it returns
|
|
10
|
+
* You add the type option to limit it to only files or directories or specify you want both
|
|
11
|
+
*
|
|
12
|
+
* @param directory
|
|
13
|
+
* @param options
|
|
14
|
+
*/
|
|
15
|
+
list(directory: string, options?: DirectoryListOptions): Promise<(string | FileInfoInterface)[]>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./directory.manager";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MatchTypeEnum } from "../enums/match-type.enum";
|
|
2
|
+
import { TypesEnum } from "../enums/types.enum";
|
|
3
|
+
import { FileInfoInterface } from "../interfaces/file-info.interface";
|
|
4
|
+
import { DirectoryListResultEnum } from "../enums/directory-list-result.enum";
|
|
5
|
+
export interface DirectoryListOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The Match type specifies how matching is done.
|
|
8
|
+
* "BASE": Means you're matching the base filename without the extension and without the path such as "results"
|
|
9
|
+
* "EXT": Means you're matching file extensions (without leading ".") such as "jpeg"
|
|
10
|
+
* "FILE_NAME": Means you're matching the base filename and extension such as "results.jpeg"
|
|
11
|
+
*/
|
|
12
|
+
matchType?: MatchTypeEnum;
|
|
13
|
+
/**
|
|
14
|
+
* (defaults to empty which matches everything)
|
|
15
|
+
* string means you're looking for an exact match with matchWhat setting
|
|
16
|
+
* regex is a regex that will be applied to the matchWhat setting
|
|
17
|
+
* function is a custom callback function - callback({filename, basename, ext, fullPath, type})
|
|
18
|
+
* return true to include in results
|
|
19
|
+
* return false to exclude from results
|
|
20
|
+
* can return a promise that will be awaited to resolve to true|false
|
|
21
|
+
* promise rejecting aborts the whole process
|
|
22
|
+
*/
|
|
23
|
+
match?: string | RegExp | ((file: FileInfoInterface) => boolean | Promise<boolean>);
|
|
24
|
+
/**
|
|
25
|
+
* matchCaseInsensitive: true|false (defaults to true)
|
|
26
|
+
* Only applies when match is a string
|
|
27
|
+
*/
|
|
28
|
+
matchCaseInsensitive?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* recurse: true|false|function (defaults to false)
|
|
31
|
+
* true is recurse into sub-directories
|
|
32
|
+
* false is no recurse
|
|
33
|
+
* function is to call this function on each sub-directory
|
|
34
|
+
* return true = recurse into this sub-directory
|
|
35
|
+
* return false = don't recurse into this sub-directory
|
|
36
|
+
* callback({filename, basename, ext, fullPath, type})
|
|
37
|
+
* can return a promise that will be awaited to resolve to true|false
|
|
38
|
+
* promise rejecting aborts the whole process
|
|
39
|
+
*/
|
|
40
|
+
recurse?: true | false | ((file: FileInfoInterface) => boolean | Promise<boolean>);
|
|
41
|
+
/**
|
|
42
|
+
* Types determines what is being returned or listed.
|
|
43
|
+
* types: "files"|"dirs"|"both" (defaults to "files")
|
|
44
|
+
* files is return only files (skip directories)
|
|
45
|
+
* dirs is return only directories (skip files)
|
|
46
|
+
* both is to return both files and directories
|
|
47
|
+
*/
|
|
48
|
+
types?: TypesEnum;
|
|
49
|
+
/**
|
|
50
|
+
* resultType: "objects"|"names" (defaults to "names")
|
|
51
|
+
* objects is array of {filename, basename, ext, fullPath, type} objects
|
|
52
|
+
* fulLPath is array of fullPath strings
|
|
53
|
+
*/
|
|
54
|
+
resultType?: DirectoryListResultEnum;
|
|
55
|
+
/**
|
|
56
|
+
* skipTopLevelFiles: true|false (defaults to false)
|
|
57
|
+
* only process directories on the top level, skip top level files
|
|
58
|
+
*/
|
|
59
|
+
skipTopLevelFiles?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* results (optional)
|
|
62
|
+
* If you pass an array into options.results, then this function call will add items to that array
|
|
63
|
+
* If you don't pass an array, a new array will be created
|
|
64
|
+
* The populated array will be the resolved value of the promise that is returned
|
|
65
|
+
*/
|
|
66
|
+
results?: (string | FileInfoInterface)[];
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./directory-list.options";
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pristine-ts/file",
|
|
3
|
+
"version": "0.0.229",
|
|
4
|
+
"description": "",
|
|
5
|
+
"module": "dist/lib/esm/file.module.js",
|
|
6
|
+
"main": "dist/lib/cjs/file.module.js",
|
|
7
|
+
"types": "dist/types/file.module.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
|
|
10
|
+
"prepublish": "npm run build",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"test:cov": "jest --coverage"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@pristine-ts/common": "^0.0.229"
|
|
24
|
+
},
|
|
25
|
+
"jest": {
|
|
26
|
+
"transform": {
|
|
27
|
+
".(ts|tsx)": "ts-jest"
|
|
28
|
+
},
|
|
29
|
+
"globals": {
|
|
30
|
+
"ts-jest": {
|
|
31
|
+
"tsconfig": {
|
|
32
|
+
"strictNullChecks": false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"testEnvironment": "node",
|
|
37
|
+
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
|
|
38
|
+
"moduleFileExtensions": [
|
|
39
|
+
"ts",
|
|
40
|
+
"tsx",
|
|
41
|
+
"js"
|
|
42
|
+
],
|
|
43
|
+
"coveragePathIgnorePatterns": [
|
|
44
|
+
"/node_modules/",
|
|
45
|
+
"/test/"
|
|
46
|
+
],
|
|
47
|
+
"coverageThreshold": {
|
|
48
|
+
"global": {
|
|
49
|
+
"branches": 90,
|
|
50
|
+
"functions": 95,
|
|
51
|
+
"lines": 95,
|
|
52
|
+
"statements": 95
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"collectCoverageFrom": [
|
|
56
|
+
"src/*.{js,ts}"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "0c1f6875e065015304d89e9bba4fbcc5dbb052d6"
|
|
60
|
+
}
|
package/readme.md
ADDED