ember-native-class-codemod
ember-native-class-codemod copied to clipboard
Passing boolean flag options not working correctly
In the documentation it says you can disable various features by setting a flag to false
. For example, --classic-decorator=false
will disable the insertion of the @classic
decorator.
This doesn't work correctly because passing --classic-decorator=false
actually gets transformed to { classicDecorator: 'false' }
. The classicDecorator
value is actually a string value of false
and therefore truthy.
I originally opened this in the closed PR https://github.com/ember-codemods/ember-native-class-codemod/pull/212 but I revisited the approach.
I've introduced a change where we now use yargs
parse the options into their correct types, i.e. Boolean and String. This means Booleans are now accurately represented.
I haven't added a test but any suggestions on how to test this are welcome.
/cc @NullVoxPopuli @rwjblue
Sorry, ignore for now while I resolve some problems
@rwjblue so I'm not even sure if I'm on the right track here 😅 Is this what you had in mind when we initially discussed the codemod setting its own options?
If so, I guess the problem I'm at now is that to get the actual passed options into codemod-cli I need to push them into an array as that's what codemod-cli#runTransform
expects, which kind of negates the yargs
work already done. Or is it possible to update codemod-cli#runTransform
to take a yargs
object and not call yargs.parse
if it's an object?