sampledata:deploy fails with the message «No such file or directory» when a third-party composer package contains multiple Magento 2 modules (and my fix)

My third-party composer package contains multiple Magento 2 modules.
There is the single composer.json and multiple registration.php (for each module):

When I run bin/magento sampledata:deploy it leads to the error:

[ErrorException]
file_get_contents(app/code/Df/Api/composer.json): failed to open stream: No such file or directory

My fix

Locate the line:

Add the following code just before:

if (!is_file($file)) {
	continue;
}