Schematics fail when moving a file and updating its content #21083
Labels
area: @angular-devkit/schematics
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
Milestone
🐞 Bug report
Description
When a schematic moves a file and update its content, an error is thrown saying that the file doesn't exist:
ERROR! docs/README.md does not exist. The Schematic workflow failed. See above.
If the file is not moved, it all works fine.
🔬 Minimal Reproduction
A minimal reproduction of this issue can be found in https://github.com/leosvelperez/schematics-overwrite-issue.
The repo provides 2 schematics, one broken and one successful. The broken one does the following operations:
/README.md
to/docs/README.md
./docs/README.md
content.The successful schematics just update the
/README.md
content and it works fine.Below are the steps to run the schematic (it runs in dry run mode, but this doesn't affect the outcome):
The issue most likely happens because when an action is validated, it validates if the file exists, and depending on the kind of action and the result it will result in an error. The function that checks for the existence of the file https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/src/sink/host.ts#L36 is not checking if the file path is in any tuple of the
_filesToRename
object as part of theto
(destination).🔥 Exception or Error
ERROR! docs/README.md does not exist. The Schematic workflow failed. See above.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: