@e-mc/file-manager 0.13.0 → 0.13.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.
Files changed (3) hide show
  1. package/README.md +10 -10
  2. package/index.js +8 -8
  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.0/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.13.1/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.0/lib/squared.d.ts
300
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/asset.d.ts
301
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/core.d.ts
302
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/filemanager.d.ts
303
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/logger.d.ts
304
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/module.d.ts
305
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/node.d.ts
306
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/request.d.ts
307
- - https://www.unpkg.com/@e-mc/types@0.13.0/lib/settings.d.ts
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
308
308
 
309
309
  * https://www.npmjs.com/package/@types/node
310
310
 
package/index.js CHANGED
@@ -132,7 +132,7 @@ function bundleTorrent(host, files, mimeType, encoding) {
132
132
  return output;
133
133
  }
134
134
  function recurseDir(output, subDirs, options) {
135
- const { ignore, sortBy, recursive } = options;
135
+ const { ignore, ignoreRoot, sortBy, recursive } = options;
136
136
  const baseDir = path.join(...subDirs);
137
137
  const items = fs.readdirSync(baseDir, { withFileTypes: true })
138
138
  .filter(item => item.name)
@@ -154,7 +154,7 @@ function recurseDir(output, subDirs, options) {
154
154
  output.push(pathname);
155
155
  }
156
156
  }
157
- else if (recursive) {
157
+ else if (recursive && (subDirs.length > 0 || !ignoreRoot.includes(item.name))) {
158
158
  recurseDir(output, subDirs.concat(item.name), options);
159
159
  }
160
160
  }
@@ -196,7 +196,7 @@ function filterPaths(rootDir, values, options = {}) {
196
196
  const [glob, globAbs] = createMatchNegate(include, options);
197
197
  for (let i = 0; i < values.length; ++i) {
198
198
  const value = values[i];
199
- if (!isMatch(value, glob) && !isMatch(value.substring(rootDir.length), globAbs)) {
199
+ if (!isMatch(value, globAbs) && !isMatch(value.substring(rootDir.length), glob)) {
200
200
  values.splice(i--, 1);
201
201
  }
202
202
  }
@@ -210,7 +210,7 @@ function filterPaths(rootDir, values, options = {}) {
210
210
  const [glob, globAbs] = createMatchNegate(exclude, options);
211
211
  for (let i = 0; i < values.length; ++i) {
212
212
  const value = values[i];
213
- if (isMatch(value, glob) || isMatch(value.substring(rootDir.length), globAbs)) {
213
+ if (isMatch(value, globAbs) || isMatch(value.substring(rootDir.length), glob)) {
214
214
  values.splice(i--, 1);
215
215
  }
216
216
  }
@@ -321,7 +321,7 @@ function setBufferTarget(item, buffer) {
321
321
  }
322
322
  }
323
323
  async function doVerifyChecksum(root, from, options, nested) {
324
- const { digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], verbose = true, joinRoot } = options;
324
+ const { digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], ignoreRoot = [], verbose = true, joinRoot } = options;
325
325
  const parent = recursive === 1 && typeof verbose !== 'number';
326
326
  let algorithm = options.algorithm;
327
327
  from ||= checksumFile(algorithm);
@@ -349,7 +349,7 @@ async function doVerifyChecksum(root, from, options, nested) {
349
349
  const filename = path.basename(from);
350
350
  const files = [];
351
351
  from = joinRoot ? path.join(root, filename) : path.resolve(from);
352
- recurseDir(files, [root], { ignore: [...ignore, from], sortBy, recursive });
352
+ recurseDir(files, [root], { ignore: [...ignore, from], ignoreRoot, sortBy, recursive });
353
353
  const items = fs.readFileSync(from, 'utf8').split('\n').map(item => {
354
354
  const index = item.indexOf(' ');
355
355
  return [item.substring(0, index), path.join(root, item.substring(index + 1))];
@@ -1448,13 +1448,13 @@ class FileManager extends core_1.Host {
1448
1448
  else {
1449
1449
  options ||= {};
1450
1450
  }
1451
- const { algorithm, digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], verbose = false, joinRoot } = options;
1451
+ const { algorithm, digestEncoding = options.digest, sortBy = 0, recursive = false, ignore = [], ignoreRoot = [], verbose = false, joinRoot } = options;
1452
1452
  to ||= checksumFile(algorithm);
1453
1453
  let result = [];
1454
1454
  try {
1455
1455
  const filename = path.basename(to);
1456
1456
  to = joinRoot ? path.join(root, to) : path.resolve(to);
1457
- recurseDir(result, [root], { ignore: [...ignore, to], sortBy, recursive });
1457
+ recurseDir(result, [root], { ignore: [...ignore, to], ignoreRoot, sortBy, recursive });
1458
1458
  const output = [];
1459
1459
  for (const pathname of result = filterPaths(root, result, options)) {
1460
1460
  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.0",
3
+ "version": "0.13.1",
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.0",
23
- "@e-mc/compress": "0.13.0",
24
- "@e-mc/core": "0.13.0",
25
- "@e-mc/document": "0.13.0",
26
- "@e-mc/image": "0.13.0",
27
- "@e-mc/request": "0.13.0",
28
- "@e-mc/task": "0.13.0",
29
- "@e-mc/types": "0.13.0",
30
- "@e-mc/watch": "0.13.0",
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",
31
31
  "chalk": "4.1.2",
32
32
  "diff": "^8.0.2",
33
33
  "picomatch": "^4.0.3"