@e-mc/file-manager 0.10.6 → 0.10.7

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.
Files changed (3) hide show
  1. package/README.md +10 -10
  2. package/index.js +23 -13
  3. package/package.json +10 -10
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.10.6/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.7/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
@@ -305,15 +305,15 @@ NOTE: **FileManager** is a sub-class of [Host](https://www.npmjs.com/package/@e-
305
305
 
306
306
  ## References
307
307
 
308
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/squared.d.ts
309
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/asset.d.ts
310
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/core.d.ts
311
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/filemanager.d.ts
312
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/logger.d.ts
313
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/module.d.ts
314
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/node.d.ts
315
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/request.d.ts
316
- - https://www.unpkg.com/@e-mc/types@0.10.6/lib/settings.d.ts
308
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/squared.d.ts
309
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/asset.d.ts
310
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/core.d.ts
311
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/filemanager.d.ts
312
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/logger.d.ts
313
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/module.d.ts
314
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/node.d.ts
315
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/request.d.ts
316
+ - https://www.unpkg.com/@e-mc/types@0.10.7/lib/settings.d.ts
317
317
 
318
318
  * https://www.npmjs.com/package/@types/node
319
319
 
package/index.js CHANGED
@@ -136,7 +136,7 @@ function unsetContent(item) {
136
136
  item.buffer = null;
137
137
  }
138
138
  if ('sourceUTF8' in item) {
139
- item.sourceUTF8 = '';
139
+ item.sourceUTF8 = undefined;
140
140
  }
141
141
  }
142
142
  function bundleTorrent(host, files, mimeType, encoding) {
@@ -176,7 +176,7 @@ function recurseDir(output, subDirs, options) {
176
176
  for (const item of items) {
177
177
  if (!item.isDirectory()) {
178
178
  const pathname = path.join(baseDir, item.name);
179
- if (!ignore.includes(pathname)) {
179
+ if (!ignore.includes(pathname) && !(item.isSymbolicLink() && core_1.Host.isDir(pathname))) {
180
180
  output.push(pathname);
181
181
  }
182
182
  }
@@ -217,24 +217,33 @@ function checkHash(host, localUri, output, options, data) {
217
217
  }
218
218
  return true;
219
219
  }
220
- function validatePaths(values, patterns, include, dot) {
221
- const items = patterns.map(value => isMatchRoot(value) ? [core_1.Permission.toPosix(path.resolve(value)), { nocase: core_1.Host.PLATFORM_WIN32, dot }] : [sanitizePath(value), { matchBase: true, nocase: core_1.Host.PLATFORM_WIN32, dot }]);
220
+ function validatePaths(rootDir, values, patterns, include, dot) {
221
+ const items = patterns.map(value => {
222
+ let invert = false;
223
+ if (!include && value.startsWith('!')) {
224
+ value = value.substring(1);
225
+ invert = true;
226
+ }
227
+ const matchBase = !isMatchRoot(value = core_1.Permission.toPosix(value));
228
+ return [pm(value, { posixSlashes: true, windows: true, nocase: core_1.Host.PLATFORM_WIN32, dot, matchBase }), path.isAbsolute(value), invert];
229
+ });
222
230
  return values.filter(value => {
223
- for (const [pattern, options] of items) {
224
- if (pm.isMatch(core_1.Permission.toPosix(value), pattern, options)) {
225
- return include;
231
+ for (const [pattern, absolute, invert] of items) {
232
+ if (pattern(absolute ? value : value.substring(rootDir.length))) {
233
+ return invert ? !include : include;
226
234
  }
227
235
  }
228
236
  return !include;
229
237
  });
230
238
  }
231
- function filterPaths(values, include, exclude, dot) {
239
+ function filterPaths(rootDir, values, include, exclude, dot) {
240
+ rootDir = core_1.Host.normalizePath(rootDir, 2);
232
241
  if (include) {
233
242
  if ((0, types_1.isString)(include)) {
234
243
  include = [include];
235
244
  }
236
245
  if ((0, types_1.isArray)(include)) {
237
- return validatePaths(values, include, true, dot);
246
+ values = validatePaths(rootDir, values, include, true, dot);
238
247
  }
239
248
  }
240
249
  if (exclude) {
@@ -242,7 +251,7 @@ function filterPaths(values, include, exclude, dot) {
242
251
  exclude = [exclude];
243
252
  }
244
253
  if ((0, types_1.isArray)(exclude)) {
245
- return validatePaths(values, exclude, false, dot);
254
+ return validatePaths(rootDir, values, exclude, false, dot);
246
255
  }
247
256
  }
248
257
  return values;
@@ -544,7 +553,7 @@ async function doVerifyChecksum(root, from, options, nested) {
544
553
  const index = item.indexOf(' ');
545
554
  return [item.substring(0, index), path.join(root, item.substring(index + 1))];
546
555
  });
547
- const checked = include || exclude ? filterPaths(items.map(item => item[1]), include, exclude, options.dot) : null;
556
+ const checked = include || exclude ? filterPaths(root, items.map(item => item[1]), include, exclude, options.dot) : null;
548
557
  let valid;
549
558
  for (const [previous, pathname] of items) {
550
559
  if (checked !== null && !checked.includes(pathname) || recursive === 1 && path.basename(pathname) === filename) {
@@ -1607,10 +1616,11 @@ class FileManager extends core_1.Host {
1607
1616
  let result = [];
1608
1617
  try {
1609
1618
  const filename = path.basename(to);
1619
+ const output = [];
1610
1620
  to = joinRoot ? path.join(root, to) : path.resolve(to);
1611
1621
  recurseDir(result, [root], { ignore: [...ignore, to], sortBy, recursive });
1612
- const output = [];
1613
- for (const pathname of result = filterPaths(result, include, exclude, options.dot)) {
1622
+ result = filterPaths(root, result, include, exclude, options.dot);
1623
+ for (const pathname of result) {
1614
1624
  if (recursive === 1 && path.basename(pathname) === filename) {
1615
1625
  continue;
1616
1626
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/file-manager",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "description": "FileManager constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,15 +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.10.6",
24
- "@e-mc/compress": "0.10.6",
25
- "@e-mc/core": "0.10.6",
26
- "@e-mc/document": "0.10.6",
27
- "@e-mc/image": "0.10.6",
28
- "@e-mc/request": "0.10.6",
29
- "@e-mc/task": "0.10.6",
30
- "@e-mc/types": "0.10.6",
31
- "@e-mc/watch": "0.10.6",
23
+ "@e-mc/cloud": "0.10.7",
24
+ "@e-mc/compress": "0.10.7",
25
+ "@e-mc/core": "0.10.7",
26
+ "@e-mc/document": "0.10.7",
27
+ "@e-mc/image": "0.10.7",
28
+ "@e-mc/request": "0.10.7",
29
+ "@e-mc/task": "0.10.7",
30
+ "@e-mc/types": "0.10.7",
31
+ "@e-mc/watch": "0.10.7",
32
32
  "chalk": "4.1.2",
33
33
  "diff": "^5.2.0",
34
34
  "picomatch": "^4.0.2",