node-confmanager 1.6.0 → 1.6.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 +1 -1
  2. package/lib/main.js +14 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -40,7 +40,7 @@ $ npm install node-confmanager
40
40
 
41
41
  ```bash
42
42
  node mysoft.js -d
43
- node mysoft.js --debug
43
+ node mysoft.js --debug # if "skeleton" is defined as a boolean
44
44
  node mysoft.js --debug "true"
45
45
  node mysoft.js --debug "yes"
46
46
  node mysoft.js --debug "y"
package/lib/main.js CHANGED
@@ -60,19 +60,27 @@ module.exports = class ConfManager extends Container {
60
60
  if (arg.startsWith("-")) {
61
61
 
62
62
  const isShortcut = !arg.startsWith("--");
63
-
64
63
  const argument = arg.slice(isShortcut ? 1 : 2, arg.length);
65
64
 
66
- if (!isShortcut || this.shortcuts[argument]) {
65
+ if (argument && (!isShortcut || this.shortcuts[argument])) {
67
66
 
68
67
  const key = isShortcut ? this.shortcuts[argument] : argument;
69
68
 
70
- if (i + 1 < args.length && -1 >= args[i + 1].indexOf("--")) {
71
- this.set(key, args[i + 1]);
72
- }
73
- else if (this.skeletons[key] && "boolean" === this.skeletons[key]) {
69
+ if (this.skeletons[key] && "boolean" === this.skeletons[key]) {
74
70
  this.set(key, true);
75
71
  }
72
+ else if (i + 1 >= args.length) {
73
+ throw new ReferenceError("Missing value for \"" + argument + "\" key (no more arguments)");
74
+ }
75
+ else if (args[i + 1].startsWith("--")) {
76
+ throw new ReferenceError("Missing value for \"" + argument + "\" key (next argument is a valid key)");
77
+ }
78
+ else if (args[i + 1].startsWith("-") && this.shortcuts[args[i + 1].slice(1)]) {
79
+ throw new ReferenceError("Missing value for \"" + argument + "\" key (next argument is a valid shortcut)");
80
+ }
81
+ else {
82
+ this.set(key, args[i + 1]);
83
+ }
76
84
 
77
85
  }
78
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-confmanager",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "A configuration manager",
5
5
  "main": "lib/main.js",
6
6
  "typings": "lib/index.d.ts",