Skip to content

Conversation

patocallaghan
Copy link
Contributor

@patocallaghan patocallaghan commented Nov 11, 2019

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 #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

@patocallaghan
Copy link
Contributor Author

Sorry, ignore for now while I resolve some problems

@patocallaghan
Copy link
Contributor Author

@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?

gitKrystan added a commit to gitKrystan/ember-native-class-codemod that referenced this pull request Mar 2, 2023
Coerce 'true'/'false' into actual booleans (Fixes ember-codemods#223)
Better error messages
gitKrystan added a commit to gitKrystan/ember-native-class-codemod that referenced this pull request Mar 2, 2023
Coerce 'true'/'false' into actual booleans (Fixes ember-codemods#223)
Better error messages
gitKrystan added a commit to gitKrystan/ember-native-class-codemod that referenced this pull request Mar 2, 2023
Coerce 'true'/'false' into actual booleans (Fixes ember-codemods#223)
Better error messages
gitKrystan added a commit to gitKrystan/ember-native-class-codemod that referenced this pull request Mar 2, 2023
Coerce 'true'/'false' into actual booleans (Fixes ember-codemods#223)
Better error messages
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

Successfully merging this pull request may close these issues.

1 participant