@e-mc/file-manager 0.13.1 → 0.13.3

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 +18 -6
  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.13.1/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.13.3/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { ChecksumValue, DataSource, IncrementalMatch, TaskAction } from "./squared";
@@ -296,15 +296,15 @@ NOTE: **FileManager** is a sub-class of [Host](https://www.npmjs.com/package/@e-
296
296
 
297
297
  ## References
298
298
 
299
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/squared.d.ts
300
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/asset.d.ts
301
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/core.d.ts
302
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/filemanager.d.ts
303
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/logger.d.ts
304
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/module.d.ts
305
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/node.d.ts
306
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/request.d.ts
307
- - https://www.unpkg.com/@e-mc/types@0.13.1/lib/settings.d.ts
299
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/squared.d.ts
300
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/asset.d.ts
301
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/core.d.ts
302
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/filemanager.d.ts
303
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/logger.d.ts
304
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/module.d.ts
305
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/node.d.ts
306
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/request.d.ts
307
+ - https://www.unpkg.com/@e-mc/types@0.13.3/lib/settings.d.ts
308
308
 
309
309
  * https://www.npmjs.com/package/@types/node
310
310
 
package/index.js CHANGED
@@ -133,9 +133,19 @@ function bundleTorrent(host, files, mimeType, encoding) {
133
133
  }
134
134
  function recurseDir(output, subDirs, options) {
135
135
  const { ignore, ignoreRoot, sortBy, recursive } = options;
136
+ const fromDir = subDirs.length > 1 ? path.posix.join(...subDirs.slice(1)) : null;
137
+ if (ignoreRoot.length > 0 && fromDir && pm.isMatch(fromDir + '/', ignoreRoot, core_1.Host.PLATFORM_WIN32 ? { nocase: true } : undefined)) {
138
+ return output;
139
+ }
140
+ const ignoreGlob = ignore.length > 0 ? pm(ignore, core_1.Host.PLATFORM_WIN32 ? { nocase: true, matchBase: true } : { matchBase: true }) : null;
136
141
  const baseDir = path.join(...subDirs);
137
142
  const items = fs.readdirSync(baseDir, { withFileTypes: true })
138
- .filter(item => item.name)
143
+ .filter(item => {
144
+ if (ignoreGlob && ignoreGlob(fromDir ? path.posix.join(fromDir, item.name) : item.name)) {
145
+ return false;
146
+ }
147
+ return item.name;
148
+ })
139
149
  .sort((a, b) => {
140
150
  if (sortBy > 0) {
141
151
  if (a.isDirectory() && !b.isDirectory()) {
@@ -150,11 +160,12 @@ function recurseDir(output, subDirs, options) {
150
160
  for (const item of items) {
151
161
  if (!item.isDirectory()) {
152
162
  const pathname = path.join(baseDir, item.name);
153
- if (!ignore.includes(pathname)) {
154
- output.push(pathname);
163
+ if (item.isSymbolicLink() && core_1.Host.isDir(pathname) || ignore.length > 0 && (core_1.Host.PLATFORM_WIN32 ? ignore.includes(pathname.toLowerCase()) : ignore.includes(pathname))) {
164
+ continue;
155
165
  }
166
+ output.push(pathname);
156
167
  }
157
- else if (recursive && (subDirs.length > 0 || !ignoreRoot.includes(item.name))) {
168
+ else if (recursive && (subDirs.length > 1 || (core_1.Host.PLATFORM_WIN32 ? !ignoreRoot.includes(item.name.toLowerCase()) : !ignoreRoot.includes(item.name)))) {
158
169
  recurseDir(output, subDirs.concat(item.name), options);
159
170
  }
160
171
  }
@@ -349,7 +360,7 @@ async function doVerifyChecksum(root, from, options, nested) {
349
360
  const filename = path.basename(from);
350
361
  const files = [];
351
362
  from = joinRoot ? path.join(root, filename) : path.resolve(from);
352
- recurseDir(files, [root], { ignore: [...ignore, from], ignoreRoot, sortBy, recursive });
363
+ recurseDir(files, [root], { ignore: mapPosix([...ignore, from]), ignoreRoot: mapPosix(ignoreRoot), sortBy, recursive });
353
364
  const items = fs.readFileSync(from, 'utf8').split('\n').map(item => {
354
365
  const index = item.indexOf(' ');
355
366
  return [item.substring(0, index), path.join(root, item.substring(index + 1))];
@@ -474,6 +485,7 @@ const isDownloadAll = (type) => type === 4 || type === 0;
474
485
  const hasFiles = (type, uri) => type === 3 || type === 4 || type === 0 && request_1.isRclone(uri);
475
486
  const hasIncremental = (value) => value === "etag" || value === "exists";
476
487
  const matchPathname = (value) => core_1.Host.PLATFORM_WIN32 ? value.toLowerCase() : value;
488
+ const mapPosix = (values) => core_1.Host.PLATFORM_WIN32 ? values.map(value => core_1.Permission.toPosix(value).toLowerCase()) : values;
477
489
  const formatPercent = (value) => Math.round(value).toString().padStart(3) + '%';
478
490
  const formatLength = (value, length) => `${length} ${value + (length === 1 ? '' : 's')}`;
479
491
  const checkEOF = (value) => /\n$/.test(value) ? value : value + '\n';
@@ -1454,7 +1466,7 @@ class FileManager extends core_1.Host {
1454
1466
  try {
1455
1467
  const filename = path.basename(to);
1456
1468
  to = joinRoot ? path.join(root, to) : path.resolve(to);
1457
- recurseDir(result, [root], { ignore: [...ignore, to], ignoreRoot, sortBy, recursive });
1469
+ recurseDir(result, [root], { ignore: mapPosix([...ignore, to]), ignoreRoot: mapPosix(ignoreRoot), sortBy, recursive });
1458
1470
  const output = [];
1459
1471
  for (const pathname of result = filterPaths(root, result, options)) {
1460
1472
  if (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.13.1",
3
+ "version": "0.13.3",
4
4
  "description": "FileManager constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,15 +19,15 @@
19
19
  "license": "BSD-3-Clause",
20
20
  "homepage": "https://github.com/anpham6/e-mc#readme",
21
21
  "dependencies": {
22
- "@e-mc/cloud": "0.13.1",
23
- "@e-mc/compress": "0.13.1",
24
- "@e-mc/core": "0.13.1",
25
- "@e-mc/document": "0.13.1",
26
- "@e-mc/image": "0.13.1",
27
- "@e-mc/request": "0.13.1",
28
- "@e-mc/task": "0.13.1",
29
- "@e-mc/types": "0.13.1",
30
- "@e-mc/watch": "0.13.1",
22
+ "@e-mc/cloud": "0.13.3",
23
+ "@e-mc/compress": "0.13.3",
24
+ "@e-mc/core": "0.13.3",
25
+ "@e-mc/document": "0.13.3",
26
+ "@e-mc/image": "0.13.3",
27
+ "@e-mc/request": "0.13.3",
28
+ "@e-mc/task": "0.13.3",
29
+ "@e-mc/types": "0.13.3",
30
+ "@e-mc/watch": "0.13.3",
31
31
  "chalk": "4.1.2",
32
32
  "diff": "^8.0.2",
33
33
  "picomatch": "^4.0.3"