@e-mc/file-manager 0.7.0 → 0.7.1
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 +10 -10
- package/index.d.ts +5 -5
- package/index.js +17 -5
- package/package.json +11 -10
package/LICENSE
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Copyright 2023 An Pham
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
-
|
|
5
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
-
|
|
7
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
1
|
+
Copyright 2023 An Pham
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
11
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FileManagerConstructor } from '../types/lib';
|
|
2
|
-
import type { ExternalAsset } from '../types/lib/asset';
|
|
3
|
-
|
|
4
|
-
declare const FileManager: FileManagerConstructor<ExternalAsset>;
|
|
5
|
-
|
|
1
|
+
import type { FileManagerConstructor } from '../types/lib';
|
|
2
|
+
import type { ExternalAsset } from '../types/lib/asset';
|
|
3
|
+
|
|
4
|
+
declare const FileManager: FileManagerConstructor<ExternalAsset>;
|
|
5
|
+
|
|
6
6
|
export = FileManager;
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
|
+
const pm = require("picomatch");
|
|
7
8
|
const lib_v4_1 = require("../module/lib-v4");
|
|
8
9
|
const util_1 = require("../request/util");
|
|
9
10
|
const asset_1 = require("../document/asset");
|
|
@@ -177,13 +178,24 @@ function checkHash(data, fromBuffer, options) {
|
|
|
177
178
|
}
|
|
178
179
|
return true;
|
|
179
180
|
}
|
|
180
|
-
function
|
|
181
|
+
function validatePaths(values, patterns, include, dot) {
|
|
182
|
+
const items = patterns.map(value => !value.startsWith('*') && /[\\/]/.test(value) ? [core_1.Permission.toPosix(path.resolve(value)), { nocase: PLATFORM_WIN32, dot }] : [value.replace(/\\/g, '/'), { matchBase: true, nocase: PLATFORM_WIN32, dot }]);
|
|
183
|
+
return values.filter(value => {
|
|
184
|
+
for (const [pattern, options] of items) {
|
|
185
|
+
if (pm.isMatch(core_1.Permission.toPosix(value), pattern, options)) {
|
|
186
|
+
return include;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return !include;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function filterPaths(values, include, exclude, dot) {
|
|
181
193
|
if (include) {
|
|
182
194
|
if ((0, types_1.isString)(include)) {
|
|
183
195
|
include = [include];
|
|
184
196
|
}
|
|
185
197
|
if ((0, types_1.isArray)(include)) {
|
|
186
|
-
return values
|
|
198
|
+
return validatePaths(values, include, true, dot);
|
|
187
199
|
}
|
|
188
200
|
}
|
|
189
201
|
if (exclude) {
|
|
@@ -191,7 +203,7 @@ function filterPaths(values, include, exclude) {
|
|
|
191
203
|
exclude = [exclude];
|
|
192
204
|
}
|
|
193
205
|
if ((0, types_1.isArray)(exclude)) {
|
|
194
|
-
return values
|
|
206
|
+
return validatePaths(values, exclude, false, dot);
|
|
195
207
|
}
|
|
196
208
|
}
|
|
197
209
|
return values;
|
|
@@ -645,7 +657,7 @@ class FileManager extends core_1.Host {
|
|
|
645
657
|
to = joinRoot ? path.join(root, to) : path.resolve(to);
|
|
646
658
|
recurseDir(result, [root], { ignore: [...ignore, to], sortBy, recursive });
|
|
647
659
|
const output = [];
|
|
648
|
-
for (const pathname of result = filterPaths(result, include, exclude)) {
|
|
660
|
+
for (const pathname of result = filterPaths(result, include, exclude, options.dot)) {
|
|
649
661
|
if (recursive === 1 && path.basename(pathname) === filename) {
|
|
650
662
|
continue;
|
|
651
663
|
}
|
|
@@ -698,7 +710,7 @@ class FileManager extends core_1.Host {
|
|
|
698
710
|
const index = item.indexOf(' ');
|
|
699
711
|
return [item.substring(0, index), path.join(root, item.substring(index + 1))];
|
|
700
712
|
});
|
|
701
|
-
const checked = include || exclude ? filterPaths(items.map(item => item[1]), include, exclude) : null;
|
|
713
|
+
const checked = include || exclude ? filterPaths(items.map(item => item[1]), include, exclude, options.dot) : null;
|
|
702
714
|
let valid;
|
|
703
715
|
for (const [previous, pathname] of items) {
|
|
704
716
|
if (checked !== null && !checked.includes(pathname) || recursive === 1 && path.basename(pathname) === filename) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/file-manager",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "FileManager constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,14 +20,15 @@
|
|
|
20
20
|
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "0.7.
|
|
24
|
-
"@e-mc/compress": "0.7.
|
|
25
|
-
"@e-mc/core": "0.7.
|
|
26
|
-
"@e-mc/document": "0.7.
|
|
27
|
-
"@e-mc/image": "0.7.
|
|
28
|
-
"@e-mc/request": "0.7.
|
|
29
|
-
"@e-mc/task": "0.7.
|
|
30
|
-
"@e-mc/types": "0.7.
|
|
31
|
-
"@e-mc/watch": "0.7.
|
|
23
|
+
"@e-mc/cloud": "0.7.1",
|
|
24
|
+
"@e-mc/compress": "0.7.1",
|
|
25
|
+
"@e-mc/core": "0.7.1",
|
|
26
|
+
"@e-mc/document": "0.7.1",
|
|
27
|
+
"@e-mc/image": "0.7.1",
|
|
28
|
+
"@e-mc/request": "0.7.1",
|
|
29
|
+
"@e-mc/task": "0.7.1",
|
|
30
|
+
"@e-mc/types": "0.7.1",
|
|
31
|
+
"@e-mc/watch": "0.7.1",
|
|
32
|
+
"picomatch": "^3.0.1"
|
|
32
33
|
}
|
|
33
34
|
}
|