Scaffold Append Fails When Appended File Is Empty File

Created on 9 March 2023, over 1 year ago
Updated 22 May 2024, 25 days ago

Problem/Motivation

A developer had a file they had wanting the 'drupal-scaffold" to append to another core file. When they no longer needed that stuff appended, they updated the append file to be empty. The scaffold still included the old contents of the append file in error.

Steps to reproduce

I needed to add some code to the robots.txt file. So I created a file in the location assets/my-robots-additions.txt and added this to my composer.json file:

    "extra": {
        "drupal-scaffold": {
            "file-mapping": {
                "[web-root]/robots.txt": {
                    "append": "assets/my-robots-additions.txt"
                }
            }
        }
    }

When I run composer install, it adds the line(s) I had in the append file to the robots.txt file.

After a while, the extra line(s) were no longer needed. So just removed the lines in the append file. I did not change the composer.json, but the assets/my-robots-additions.txt was updated to empty.

The next time I run composer install, the contents of the robots.txt file does not change. The append file is empty, but the scaffolded file still has the lines that are no longer in the append file.

Workaround

If I remove the lines that says to append in the composer.json and run composer install, then it removes the appended data.

Or if I update the append file to include something (a comment, some other content, etc.) then it also works.

Proposed resolution

It would be helpful if the scaffold would work with an empty file to be appended. I haven't dug into the code, so I'm not sure how that can be changed.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ComposerΒ  β†’

Last updated about 24 hours ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States dandaman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024