@e-mc/module 0.9.19 → 0.9.20

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 +6 -6
  2. package/index.js +17 -8
  3. package/package.json +2 -2
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.9.19/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.20/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -394,11 +394,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
394
394
 
395
395
  ## References
396
396
 
397
- - https://www.unpkg.com/@e-mc/types@0.9.19/lib/core.d.ts
398
- - https://www.unpkg.com/@e-mc/types@0.9.19/lib/logger.d.ts
399
- - https://www.unpkg.com/@e-mc/types@0.9.19/lib/module.d.ts
400
- - https://www.unpkg.com/@e-mc/types@0.9.19/lib/node.d.ts
401
- - https://www.unpkg.com/@e-mc/types@0.9.19/lib/settings.d.ts
397
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/core.d.ts
398
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/logger.d.ts
399
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/module.d.ts
400
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/node.d.ts
401
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/settings.d.ts
402
402
 
403
403
  * https://www.npmjs.com/package/@types/node
404
404
 
package/index.js CHANGED
@@ -535,7 +535,7 @@ function addCacheItem(map, key, data, cache) {
535
535
  key = Module.toPosix(key, true);
536
536
  if (!cache) {
537
537
  if (MEMORY_CACHE_DISK.include) {
538
- if (!MEMORY_CACHE_DISK.include.some(value => pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') }))) {
538
+ if (!MEMORY_CACHE_DISK.include.some(value => isMatch(key, value))) {
539
539
  return;
540
540
  }
541
541
  }
@@ -543,13 +543,16 @@ function addCacheItem(map, key, data, cache) {
543
543
  cache = true;
544
544
  }
545
545
  }
546
- if (!(cache && MEMORY_CACHE_DISK.exclude?.some(value => pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') })))) {
546
+ if (!(cache && MEMORY_CACHE_DISK.exclude?.some(value => isMatch(key, value)))) {
547
547
  if (!map.has(key)) {
548
548
  ++CACHE_TOTAL;
549
549
  }
550
550
  map.set(key, [Date.now(), data]);
551
551
  }
552
552
  }
553
+ function isMatch(key, value) {
554
+ return pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') && !value.includes('/') });
555
+ }
553
556
  function listDir(src, paths, depth, include, exclude, excludeDir, outFiles) {
554
557
  const srcDir = path.join(src, ...paths);
555
558
  fs.readdirSync(srcDir, { withFileTypes: true }).forEach(file => {
@@ -741,7 +744,7 @@ class Module extends EventEmitter {
741
744
  this[_f] = new AbortController();
742
745
  this[_g] = null;
743
746
  }
744
- static get VERSION() { return "0.9.19"; }
747
+ static get VERSION() { return "0.9.20"; }
745
748
  static get LOG_TYPE() { return types_1.LOG_TYPE; }
746
749
  static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
747
750
  static get MAX_TIMEOUT() { return 2147483647; }
@@ -1333,22 +1336,28 @@ class Module extends EventEmitter {
1333
1336
  filename = undefined;
1334
1337
  }
1335
1338
  if (typeof value === 'string') {
1336
- let pathname = PLATFORM_WIN32 ? value.trim() : value, convert = true;
1339
+ let pathname = PLATFORM_WIN32 ? value.trim() : value;
1337
1340
  if (normalize) {
1338
1341
  pathname = path.normalize(pathname);
1339
- convert = PLATFORM_WIN32;
1340
1342
  }
1341
- if (convert) {
1343
+ if (PLATFORM_WIN32) {
1342
1344
  pathname = pathname.replace(/(?:^\\|\\+)/g, '/');
1343
1345
  }
1344
- if (pathname = pathname.replace(/\/+$/, '')) {
1346
+ if (pathname) {
1347
+ pathname = pathname.replace(/(?<!^)\/+$/, '');
1345
1348
  if (normalize && PLATFORM_WIN32) {
1346
1349
  const match = /^([A-Z]):\//.exec(pathname);
1347
1350
  if (match) {
1348
1351
  pathname = match[1].toLowerCase() + pathname.substring(1);
1349
1352
  }
1350
1353
  }
1351
- return pathname + (filename ? '/' + filename : '');
1354
+ if (!filename) {
1355
+ return pathname;
1356
+ }
1357
+ if (pathname !== '/') {
1358
+ pathname += '/';
1359
+ }
1360
+ return pathname + filename;
1352
1361
  }
1353
1362
  }
1354
1363
  return filename || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "description": "Module base class for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.9.19",
23
+ "@e-mc/types": "0.9.20",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "16.5.4",
26
26
  "js-yaml": "^4.1.0",