-
-
Notifications
You must be signed in to change notification settings - Fork 673
Merge oldest parent first #1404
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
Conversation
This adds more tests and changes the order of merges so that cli > target > options > parent.target ...
cli/asc.js
Outdated
@@ -298,43 +317,33 @@ exports.main = function main(argv, options, callback) { | |||
return p; | |||
}); | |||
} | |||
args = optionsUtil.merge(exports.options, args, asconfig.options); | |||
args = optionsUtil.merge(exports.options, asconfig.options, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong order. The asconfig options need to be overridden by cli args.
The options.merge function puts the parent as the third parameter, preferring the second argument.
Did I miss something or mis-implement this algorithm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Just added more tests and sure enough it ignores the CLI args. The issue was that the defaults for the args was being set before the config properties were being added. So if you treat args
as the current config it will prioritize the defaults. I just changed it to not add the defaults right away so we can get just the args passed and things seem to work.
This way the "default" args aren't ever in the current config when merging.
The fixes to
Can you elaborate why this isn't working, i.e. needs temporary |
Kept cliArgs since args's defaults are needed.
We need to split up the CLI args because the defaults in |
const opts = optionsUtil.parse(argv, exports.options); | ||
let args = opts.options; | ||
const opts = optionsUtil.parse(argv, exports.options, false); | ||
let args = optionsUtil.addDefaults(exports.options, opts.options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is happening too early, and is instead intended to be performed as the last step once CLI args and asconfigs have been fully processed. For that, we just need to apply the defaults for target
and config
early, independently of populating their values. Can either hardcode these or pull them from the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed addDefaults so that it returns a new object. This way opts.options
is untouched. Then at the end of the config it is merged back into args. It was the only way I found that fixed the issues your having in #1406.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I suspect that the underlying issue is that the relative path transform is applied to imported file names, in turn stripping the .
from ./a
, resulting in the packages test trying to find a
, which resolves differently. While the changes in ordering here apparently prevent this, somehow, that doesn't look like a proper fix.
This adds more tests and changes the order of merges so that cli > target > options > parent.target ...
Now adding
expected.json
, which will be checked if--showConfig
is passed to the test runner.Changed
addDefaults
to return a new options object instead of editing the passed one.