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

Using sourcery with --watch appends to the template instead of replacing it #736

Open
rpassis opened this issue Mar 25, 2019 · 1 comment
Labels

Comments

@rpassis
Copy link

rpassis commented Mar 25, 2019

Not sure if this is a user error, expected behaviour or a bug but I just thought I'd create an issue as I couldn't find an answer to this anywhere else.

Given the following template stencil

{% for class in types.classes|annotated:"ImmutableConvertibleType" %}
{% set structName %}{{ class.name }}Struct{% endset %}
// sourcery:file:Model/{{ structName }}Struct.swift
struct {{ structName }} {}
// sourcery:end
{% endfor %}

If I run this with sourcery --watch, every time I modify/save the template, a new copy of the rendered text is appended to my output. So I end up with a file like this:

// Generated using Sourcery 0.16.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

struct ArticleStruct {}

struct ArticleStruct {}

struct ArticleStruct {}

struct ArticleStructABC {}

...etc

Interestingly, if I don't specify the output file with // sourcery:file:Model/{{ structName }}Struct.swift, it works as expected and the rendered text replaces the previous version.

Also if I run sourcery as a one-off command without --watch, it also works as expected.

Is this a bug or am I missing something?

Thanks!
Rog

@ilyapuchka ilyapuchka added the bug label Apr 27, 2019
@paultas
Copy link

paultas commented Apr 19, 2020

yep, for me it's actual too now. Anybody found a solution?
cc: @krzysztofzablocki @ilyapuchka @jschmid @DivineDominion

@art-divin art-divin added this to the 2.1.5 milestone Jan 20, 2024
@art-divin art-divin modified the milestones: 2.1.8, 2.1.9 Mar 19, 2024
@art-divin art-divin modified the milestones: 2.1.9, 2.2.0 Mar 28, 2024
@art-divin art-divin removed this from the 2.2.5 milestone Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants