@vexify-org/yaggs 5.2.0 → 5.3.0

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 (2) hide show
  1. package/lib/parser.js +19 -0
  2. package/package.json +1 -1
package/lib/parser.js CHANGED
@@ -394,6 +394,25 @@ class ArgumentParser {
394
394
  if (!ipRegex.test(value)) {
395
395
  this._handleError(`Invalid IP address for option '${name}'`);
396
396
  }
397
+ } else if (opt.type === 'file') {
398
+ const fs = require('fs');
399
+ const path = require('path');
400
+ const fullPath = path.resolve(value);
401
+ if (!fs.existsSync(fullPath)) {
402
+ this._handleError(`File not found: ${fullPath}`);
403
+ }
404
+ result[name] = fullPath;
405
+ } else if (opt.type === 'directory') {
406
+ const fs = require('fs');
407
+ const path = require('path');
408
+ const fullPath = path.resolve(value);
409
+ if (!fs.existsSync(fullPath)) {
410
+ this._handleError(`Directory not found: ${fullPath}`);
411
+ }
412
+ if (!fs.statSync(fullPath).isDirectory()) {
413
+ this._handleError(`Not a directory: ${fullPath}`);
414
+ }
415
+ result[name] = fullPath;
397
416
  } else if (opt.type === 'custom' && opt._customType) {
398
417
  result[name] = opt._customType(value);
399
418
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vexify-org/yaggs",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "A powerful CLI argument parser, better than yargs",
5
5
  "main": "index.js",
6
6
  "scripts": {