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

Custom Conflictor? #1250

Closed
bstopp opened this issue Jun 15, 2020 · 6 comments
Closed

Custom Conflictor? #1250

bstopp opened this issue Jun 15, 2020 · 6 comments
Labels

Comments

@bstopp
Copy link

bstopp commented Jun 15, 2020

Forgive me if this isn't the correct place for this - but I couldn't find anywhere else.

What is the correct way to interact with the conflictor programmatically?

I know in my generator that 3 files should be in conflict - i'm making changes to existing files.

I want to hook into the Conflictor resolution process, resolve those three files via API calls or whatever, but allow the Conflictor to deal with any other issues that may be raised.

Is this possible?

@bstopp bstopp added the needs triage Awaiting triage label Jun 15, 2020
@mshima mshima added question and removed needs triage Awaiting triage labels Jun 15, 2020
@mshima
Copy link
Member

mshima commented Jun 15, 2020

See #1239 (comment)
But the right way to implement is by creating a transform stream.
It would be something like:

this.registerTransformStream(
  through.obj(function(file, enc, cb) {
      // If the file has no state requiring action, move on
      if (file.state === null) {
        return cb();
      }
      if (file.path === this.destinationPath('anyfile')) {
        file.conflicter = 'force';
      }
  })
);

@bstopp
Copy link
Author

bstopp commented Jun 15, 2020

Is this documented anywhere other than the Issues list? (i went looking through all issues with conflictor in the name, saw this but didn't go digging, like i should have )

@bstopp
Copy link
Author

bstopp commented Jun 15, 2020

Also, does it matter when this gets registered? As in which context? (I would think should put it in conflicts but wasn't sure if it was necessary in constructor etc).

@mshima
Copy link
Member

mshima commented Jun 15, 2020

Is this documented anywhere other than the Issues list?

Not documented, would be nice to have the transform implementation documented.

Also, does it matter when this gets registered? As in which context? (I would think should put it in conflicts but wasn't sure if it was necessary in constructor etc).

Not sure it will work in the conflicts priority. But it's recommended that conflicts to be internal use only, not sure were it's documented. I think it's better to put in the constructor.

It should be registered in the root generator, registerTransformStream on secondary generators aren't executed at all because conflicter is executed at the root generator before others generators, and all conflicts have been resolved at the time conflicter is run on the others generators #819.

@mshima
Copy link
Member

mshima commented Jun 15, 2020

Closing since the question is answered.
@bstopp once you get it working, would be nice if you post your implementation here.

@mshima mshima closed this as completed Jun 15, 2020
@htoooth
Copy link

htoooth commented Nov 9, 2023

You can use this to allow you to force update the file.

conflicts() {
    this.conflicter.force = true
  }

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

3 participants