@e-mc/module 0.9.3 → 0.9.4

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 +43 -44
  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.3/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.4/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -391,11 +391,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
391
391
 
392
392
  ## References
393
393
 
394
- - https://www.unpkg.com/@e-mc/types@0.9.3/lib/core.d.ts
395
- - https://www.unpkg.com/@e-mc/types@0.9.3/lib/logger.d.ts
396
- - https://www.unpkg.com/@e-mc/types@0.9.3/lib/module.d.ts
397
- - https://www.unpkg.com/@e-mc/types@0.9.3/lib/node.d.ts
398
- - https://www.unpkg.com/@e-mc/types@0.9.3/lib/settings.d.ts
394
+ - https://www.unpkg.com/@e-mc/types@0.9.4/lib/core.d.ts
395
+ - https://www.unpkg.com/@e-mc/types@0.9.4/lib/logger.d.ts
396
+ - https://www.unpkg.com/@e-mc/types@0.9.4/lib/module.d.ts
397
+ - https://www.unpkg.com/@e-mc/types@0.9.4/lib/node.d.ts
398
+ - https://www.unpkg.com/@e-mc/types@0.9.4/lib/settings.d.ts
399
399
 
400
400
  * https://www.npmjs.com/package/@types/node
401
401
 
package/index.js CHANGED
@@ -218,7 +218,7 @@ function applyStyle(options, style) {
218
218
  return options;
219
219
  }
220
220
  function checkColorOptions(type, settings, options) {
221
- if (typeof settings !== 'object') {
221
+ if (!(0, types_1.isObject)(settings)) {
222
222
  return false;
223
223
  }
224
224
  let result = false;
@@ -653,10 +653,11 @@ function formatPercent(value, precision) {
653
653
  if (value <= 0) {
654
654
  return '0%';
655
655
  }
656
- if (value === Math.floor(value)) {
656
+ if (value === (value | 0)) {
657
657
  return value + '00%';
658
658
  }
659
- return (value * 100).toPrecision(precision) + '%';
659
+ value *= 100;
660
+ return value.toPrecision(value < 1 ? 2 : precision) + '%';
660
661
  }
661
662
  const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
662
663
  const asFile = (value) => typeof value === 'string' ? value.trim() : value instanceof URL && value.protocol === 'file:' ? url.fileURLToPath(value) : '';
@@ -695,7 +696,7 @@ class Module extends EventEmitter {
695
696
  this[_f] = new AbortController();
696
697
  this[_g] = null;
697
698
  }
698
- static get VERSION() { return "0.9.3"; }
699
+ static get VERSION() { return "0.9.4"; }
699
700
  static get LOG_TYPE() { return types_1.LOG_TYPE; }
700
701
  static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
701
702
  static get MAX_TIMEOUT() { return 2147483647; }
@@ -2470,52 +2471,50 @@ class Module extends EventEmitter {
2470
2471
  });
2471
2472
  }
2472
2473
  }
2473
- {
2474
- let dir = settings.temp_dir, write, modified;
2475
- if ((0, types_1.isPlainObject)(temp)) {
2476
- dir || (dir = temp.dir);
2477
- write = temp.write;
2478
- }
2479
- if ((0, types_1.isString)(dir) && path.isAbsolute(dir = path.normalize(dir).replace(/[\\/]$/, ''))) {
2480
- if (withinDir(dir, PROCESS_CWD)) {
2481
- dir = dir.substring(ensureDir(PROCESS_CWD).length);
2482
- }
2483
- else {
2484
- this.formatMessage(1, 'WARN', 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
2485
- dir = undefined;
2486
- }
2487
- }
2488
- if (!(0, types_1.isString)(dir)) {
2489
- dir = VALUES["temp.dir"];
2474
+ let dir = settings.temp_dir, write, modified;
2475
+ if ((0, types_1.isPlainObject)(temp)) {
2476
+ dir || (dir = temp.dir);
2477
+ write = temp.write;
2478
+ }
2479
+ if ((0, types_1.isString)(dir) && path.isAbsolute(dir = path.normalize(dir).replace(/[\\/]$/, ''))) {
2480
+ if (withinDir(dir, PROCESS_CWD)) {
2481
+ dir = dir.substring(ensureDir(PROCESS_CWD).length);
2490
2482
  }
2491
- if (typeof write === 'boolean') {
2492
- modified = VALUES["temp.write"] !== write;
2493
- VALUES["temp.write"] = write;
2483
+ else {
2484
+ this.formatMessage(1, 'WARN', 'Temp directory can only be relative', dir, { ...this.LOG_STYLE_WARN, newline: true });
2485
+ dir = undefined;
2494
2486
  }
2495
- do {
2496
- const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
2497
- if ((0, types_1.isString)(output)) {
2498
- if (index > 0) {
2499
- dir = trimDir(dir) + '_' + index;
2500
- }
2501
- if (dir !== VALUES["temp.dir"]) {
2502
- VALUES["temp.dir"] = dir;
2503
- modified = true;
2504
- }
2505
- (0, types_1.setTempDir)(TEMP_DIR = output);
2506
- break;
2487
+ }
2488
+ if (!(0, types_1.isString)(dir)) {
2489
+ dir = VALUES["temp.dir"];
2490
+ }
2491
+ if (typeof write === 'boolean') {
2492
+ modified = VALUES["temp.write"] !== write;
2493
+ VALUES["temp.write"] = write;
2494
+ }
2495
+ do {
2496
+ const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
2497
+ if ((0, types_1.isString)(output)) {
2498
+ if (index > 0) {
2499
+ dir = trimDir(dir) + '_' + index;
2507
2500
  }
2508
- if (output instanceof Error) {
2509
- this.writeFail(["Unable to create temp directory", dir], output, 32);
2501
+ if (dir !== VALUES["temp.dir"]) {
2502
+ VALUES["temp.dir"] = dir;
2503
+ modified = true;
2510
2504
  }
2511
- } while ((dir !== "tmp") && (dir = "tmp"));
2512
- if (modified) {
2513
- this.formatMessage(1, 'TEMP', ["Directory was modified", dir], TEMP_DIR + (VALUES["temp.write"] ? ' - writeable' : ''), { ...this.LOG_STYLE_NOTICE, newline: true });
2505
+ (0, types_1.setTempDir)(TEMP_DIR = output);
2506
+ break;
2514
2507
  }
2515
- settings.temp_dir = dir;
2516
- if ((0, types_1.isPlainObject)(temp)) {
2517
- temp.dir = dir;
2508
+ if (output instanceof Error) {
2509
+ this.writeFail(["Unable to create temp directory", dir], output, 32);
2518
2510
  }
2511
+ } while ((dir !== "tmp") && (dir = "tmp"));
2512
+ if (modified) {
2513
+ this.formatMessage(1, 'TEMP', ["Directory was modified", dir], TEMP_DIR + (VALUES["temp.write"] ? ' - writeable' : ''), { ...this.LOG_STYLE_NOTICE, newline: true });
2514
+ }
2515
+ settings.temp_dir = dir;
2516
+ if ((0, types_1.isPlainObject)(temp)) {
2517
+ temp.dir = dir;
2519
2518
  }
2520
2519
  return true;
2521
2520
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
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": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.9.3",
23
+ "@e-mc/types": "0.9.4",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "16.5.4",
26
26
  "js-yaml": "^4.1.0",