Skip to content
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

Inject "after" skips extra line #430

Open
gerektoolhy opened this issue Jun 28, 2023 · 0 comments
Open

Inject "after" skips extra line #430

gerektoolhy opened this issue Jun 28, 2023 · 0 comments

Comments

@gerektoolhy
Copy link

gerektoolhy commented Jun 28, 2023

Hi,

My template seems to be injecting content at a wrong place. I suspect there is something wrong with my template, its just I do not see what. This is the template file:

---
to: <%= project_path %>/docker-compose.yml
after: >
  services:
inject: true
skip_if: >
  first_line
---
first_line
last_line

This template should modify this docker-compose file, and add two new lines just below services: tag. However, injection happens after my-app: # auto-generated line, not after services:.

Below are steps to reproduce, and all files are in a branch, which you can see in this PR: https://github.com/jondot/hygen/pull/429/files


Steps to reproduce

hygen app docker_compose:add_app_db_migration --project_path ./target_file

Actual output:

diff --git a/target_file/docker-compose.yml b/target_file/docker-compose.yml
index 17173ea..f6fb3c1 100644
--- a/target_file/docker-compose.yml
+++ b/target_file/docker-compose.yml
@@ -2,6 +2,9 @@ version: "3.5"

 services:
   my-app: # auto-generated
+first_line
+last_line
+
     image: "my-image"
     container_name: container-name
     environment:

Expected output:

diff --git a/target_file/docker-compose.yml b/target_file/docker-compose.yml
index 17173ea..2ddcbc2 100644
--- a/target_file/docker-compose.yml
+++ b/target_file/docker-compose.yml
@@ -1,6 +1,9 @@
 version: "3.5"

 services:
+first_line
+last_line
+
   my-app: # auto-generated
     image: "my-image"
     container_name: container-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant