Conflicter(adapter, force)

The Conflicter is a module that can be used to detect conflict between files. Each Generator file system helpers pass files through this module to make sure they don't break a user file.

When a potential conflict is detected, we prompt the user and ask them for confirmation before proceeding with the actual write.

new Conflicter(adapter, force)

Name Type Description
adapter TerminalAdapter

The generator adapter

force Boolean

When set to true, we won't check for conflict. (the conflicter become a passthrough)

Name Type Description
force Boolean

same as the constructor argument


checkForCollision(filepath, contents, callback)

Add a file to conflicter queue

Name Type Description
filepath String

File destination path

contents String

File new contents

callback function

callback to be called once we know if the user want to proceed or not.

collision(file, cb)

Check if a file conflict with the current version on the user disk

A basic check is done to see if the file exists, if it does:

  1. Read its content from fs
  2. Compare it with the provided content
  3. If identical, mark it as is and skip the check
  4. If diverged, prepare and show up the file collision menu
Name Type Description
file Object

File object respecting this interface: { path, contents }

cb function

Callback receiving a status string ('identical', 'create', 'skip', 'force')


Process the potential conflict queue and ask the user to resolve conflict when they occur

The user is presented with the following options:

  • Y Yes, overwrite
  • n No, do not overwrite
  • a All, overwrite this and all others
  • x Exit, abort
  • d Diff, show the differences between the old and the new
  • h Help, show this help
Name Type Description
cb function

Callback once every conflict are resolved. (note that each file can specify it's own callback. See #checkForCollision())