@e-mc/module 0.10.11 → 0.10.13

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 (4) hide show
  1. package/LICENSE +3 -7
  2. package/README.md +7 -7
  3. package/index.js +18 -15
  4. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
1
  Copyright 2024 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
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
- 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.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.11/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.13/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -407,14 +407,14 @@ interface LoggerModule {
407
407
 
408
408
  ## References
409
409
 
410
- - https://www.unpkg.com/@e-mc/types@0.10.11/lib/core.d.ts
411
- - https://www.unpkg.com/@e-mc/types@0.10.11/lib/logger.d.ts
412
- - https://www.unpkg.com/@e-mc/types@0.10.11/lib/module.d.ts
413
- - https://www.unpkg.com/@e-mc/types@0.10.11/lib/node.d.ts
414
- - https://www.unpkg.com/@e-mc/types@0.10.11/lib/settings.d.ts
410
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/core.d.ts
411
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/logger.d.ts
412
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/module.d.ts
413
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/node.d.ts
414
+ - https://www.unpkg.com/@e-mc/types@0.10.13/lib/settings.d.ts
415
415
 
416
416
  * https://www.npmjs.com/package/@types/node
417
417
 
418
418
  ## LICENSE
419
419
 
420
- BSD 3-Clause
420
+ MIT
package/index.js CHANGED
@@ -138,7 +138,6 @@ const MEMORY_CACHE_DISK = {
138
138
  include: null,
139
139
  exclude: null
140
140
  };
141
- const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supported)(18, 17, 0, true);
142
141
  const REGEXP_TORRENT = /^(?:magnet:\?xt=|(?:https?|s?ftp):\/\/[^/][^\n]*?\.(?:torrent|metalink|meta4)(?:\?[^\n]*)?$)/i;
143
142
  const REGEXP_PROTOCOL = /^([a-z][a-z\d+-.]*):\/\/[^@:[\]\\^<>|\s]/i;
144
143
  const REGEXP_CLIESCAPE = /[^\w+-.,/:@]/g;
@@ -627,7 +626,7 @@ function getCacheTotal() {
627
626
  return CACHE_READTEXT.size + CACHE_READBUFFER.size + CACHE_READCJS.size;
628
627
  }
629
628
  function isMatch(key, value) {
630
- return pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') });
629
+ return pm.isMatch(key, value, { nocase: PLATFORM_WIN32, matchBase: value.startsWith('*') && !value.includes('/') });
631
630
  }
632
631
  function listDir(src, paths, depth, include, exclude, excludeDir, outFiles) {
633
632
  const srcDir = path.join(src, ...paths);
@@ -960,7 +959,7 @@ class Module extends EventEmitter {
960
959
  this[_g] = null;
961
960
  }
962
961
  static get VERSION() {
963
- return "0.10.11";
962
+ return "0.10.13";
964
963
  }
965
964
  static get LOG_TYPE() {
966
965
  return types_1.LOG_TYPE;
@@ -1533,30 +1532,33 @@ class Module extends EventEmitter {
1533
1532
  filename = undefined;
1534
1533
  }
1535
1534
  if (typeof value === 'string') {
1536
- let pathname = PLATFORM_WIN32 ? value.trim() : value, convert = true;
1535
+ let pathname = PLATFORM_WIN32 ? value.trim() : value;
1537
1536
  if (normalize) {
1538
1537
  pathname = path.normalize(pathname);
1539
- convert = PLATFORM_WIN32;
1540
1538
  }
1541
- if (convert) {
1539
+ if (PLATFORM_WIN32) {
1542
1540
  pathname = pathname.replace(/(?:^\\|\\+)/g, '/');
1543
1541
  }
1544
- if (pathname = pathname.replace(/\/+$/, '')) {
1542
+ if (pathname) {
1543
+ pathname = pathname.replace(/(?<!^)\/+$/, '');
1545
1544
  if (normalize && PLATFORM_WIN32) {
1546
1545
  const match = /^([A-Z]):\//.exec(pathname);
1547
1546
  if (match) {
1548
1547
  pathname = match[1].toLowerCase() + pathname.substring(1);
1549
1548
  }
1550
1549
  }
1551
- return pathname + (filename ? '/' + filename : '');
1550
+ if (!filename) {
1551
+ return pathname;
1552
+ }
1553
+ if (pathname !== '/') {
1554
+ pathname += '/';
1555
+ }
1556
+ return pathname + filename;
1552
1557
  }
1553
1558
  }
1554
1559
  return filename || '';
1555
1560
  }
1556
1561
  static isURL(value, ...exclude) {
1557
- if (exclude.length === 0 && SUPPORTED_CANPARSE) {
1558
- return URL.canParse(value);
1559
- }
1560
1562
  const match = REGEXP_PROTOCOL.exec(value);
1561
1563
  return !!match && !exclude.includes(match[1].toLowerCase());
1562
1564
  }
@@ -1922,7 +1924,7 @@ class Module extends EventEmitter {
1922
1924
  if (!(outDir && this.isDir(outDir))) {
1923
1925
  return Promise.reject(errorDirectory(asFile(src) || "Unknown"));
1924
1926
  }
1925
- const pmOpts = { posixSlashes: true, windows: true, nocase: PLATFORM_WIN32 };
1927
+ const pmOpts = PLATFORM_WIN32 ? { nocase: true, windows: true, posixSlashes: true } : {};
1926
1928
  let exclude, excludeDir, recursive;
1927
1929
  if ((0, types_1.isObject)(options)) {
1928
1930
  if (options.matchBase) {
@@ -1939,8 +1941,9 @@ class Module extends EventEmitter {
1939
1941
  const items = Array.isArray(exclude) ? exclude : [exclude];
1940
1942
  exclude = [];
1941
1943
  for (const value of items) {
1942
- if (/^[^\\/][^*]+[\\/]$/.test(value) && !(0, types_1.hasGlob)(value)) {
1943
- (excludeDir ||= []).push(this.normalizePath(value, 4));
1944
+ const dirEnd = value.endsWith('/') ? /^[^/][^*]+\/$/ : value.endsWith('\\') ? /^[^\\][^*]+\\$/ : null;
1945
+ if (dirEnd?.test(value) && !(0, types_1.hasGlob)(value)) {
1946
+ (excludeDir ||= []).push(this.toPosix(value, true));
1944
1947
  }
1945
1948
  else {
1946
1949
  exclude.push(value);
@@ -2763,7 +2766,7 @@ class Module extends EventEmitter {
2763
2766
  dir = dir.substring(ensureDir(PROCESS_CWD).length);
2764
2767
  }
2765
2768
  else {
2766
- this.formatMessage(1, "WARN!", 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
2769
+ this.formatMessage(1, "WARN!", "Not permitted to set absolute path", dir, { ...this.LOG_STYLE_WARN, newline: true });
2767
2770
  dir = VALUES["temp.dir"];
2768
2771
  }
2769
2772
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.10.11",
3
+ "version": "0.10.13",
4
4
  "description": "Module base class for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,10 +17,10 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD-3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.10.11",
23
+ "@e-mc/types": "0.10.13",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "^18.7.0",
26
26
  "js-yaml": "^4.1.0",