When executing targets by postTargets options, the original options for the target is always treated as unparsed options and will be appended to the end of the command-line command.
For example, the target build using nx internal executor nx:run-script configured like this.
Before runing the build script from postTargets, the following code read options from the project's config and pass the options as the second argument to runExecutor which is treated as override options.
And override options will transform to command line arguments. Which means { "script": "build" } is transformed to --script=build and will be appended to the end of the origin command tsc -p tsconfig.json.
Finally, the command is unexpectedly changed from tsc -p tsconfig.json to tsc -p tsconfig.json --script=build.
So, i am wondering if the readTargetOptions is necessary or if this should be considered a bug.
When executing targets by postTargets options, the original
options
for the target is always treated asunparsed
options and will be appended to the end of the command-line command.For example, the target
build
using nx internal executornx:run-script
configured like this.Before runing the
build
script from postTargets, the following code read options from the project's config and pass the options as the second argument torunExecutor
which is treated as override options.https://github.com/jscutlery/semver/blob/048c4b29686e7fbd1a25e5f3c0cb60350733b481/packages/semver/src/executors/version/utils/post-target.ts#L33-L42
https://github.com/nrwl/nx/blob/458f2cc1e8511c60389a8edad233ab3f77afd410/packages/nx/src/command-line/run/run.ts#L261-L271
https://github.com/nrwl/nx/blob/458f2cc1e8511c60389a8edad233ab3f77afd410/packages/nx/src/utils/serialize-overrides-into-command-line.ts#L3-L15
And override options will transform to command line arguments. Which means
{ "script": "build" }
is transformed to--script=build
and will be appended to the end of the origin commandtsc -p tsconfig.json
.Finally, the command is unexpectedly changed from
tsc -p tsconfig.json
totsc -p tsconfig.json --script=build
.So, i am wondering if the
readTargetOptions
is necessary or if this should be considered a bug.