Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STRING is casting empty string to 'true' #214

Open
ashishtilara opened this issue Sep 6, 2021 · 0 comments
Open

STRING is casting empty string to 'true' #214

ashishtilara opened this issue Sep 6, 2021 · 0 comments

Comments

@ashishtilara
Copy link

When I intentionally provide empty value to option, Caporal turns it into 'true', I resolved it using custom validator using following

  static isString(val) {
    if (typeof val !== 'string') {
      throw new Error('invalid type');
    }
    return val;
  }

When I provide a number, it fails so that is all good. but the error message contains


error: invalid type

<path>/node_modules/@caporal/core/dist/index.js:1
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=29)}([function(t,e){t.exports=require("chalk")},function(t,e){t.exports=require("path")},function(t,e){t.exports=require("util")},function(t,e){t.exports=require("lodash/filter")},function(t,e){t.exports=require("lodash/flatMap")},function.....




fe: invalid type
    at t (<path>/node_modules/@caporal/core/dist/index.js:1:21469)
    at ye (<path>/node_modules/@caporal/core/dist/index.js:1:21518)
    at <path>/node_modules/@caporal/core/dist/index.js:1:23317
    at <path>/node_modules/@caporal/core/dist/index.js:1:23339
    at <path>/node_modules/@caporal/core/node_modules/lodash/_baseReduce.js:18:9
    at <path>/node_modules/@caporal/core/node_modules/lodash/_createBaseFor.js:17:11
    at baseForOwn (<path>/node_modules/@caporal/core/node_modules/lodash/_baseForOwn.js:13:20)
    at <path>/node_modules/@caporal/core/node_modules/lodash/_createBaseEach.js:17:14
    at baseReduce (<path>/node_modules/@caporal/core/node_modules/lodash/_baseReduce.js:15:3)
    at reduce (<path>/node_modules/@caporal/core/node_modules/lodash/reduce.js:48:10) {
  meta: {}
}

it prints entire /node_modules/@caporal/core/dist/index.js file and then the error trace. Any clues on what's going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant