new Conflicter (adapter, force, bail)
Parameters:
| 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) |
bail |
Boolean |
When set to true, we will abort on first conflict. (used for testing reproducibility) |
Properties:
| Name | Type | Description |
|---|---|---|
force |
Boolean |
same as the constructor argument |
Methods
-
_detectConflict (file) → {Boolean}
-
Detect conflicts between file contents at
filepathwith thecontentspassed to the functionIf
filepathpoints to a folder, we'll always return true.Based on detect-conflict module
Parameters:
Name Type Description fileObject File object respecting this interface: { path, contents }
Returns:
Boolean -trueif there's a conflict,falseotherwise. -
_printDiff (file)
-
Print the file differences to console
Parameters:
Name Type Description fileObject File object respecting this interface: { path, contents }
-
checkForCollision (filepath, contents, callback)
-
Add a file to conflicter queue
Parameters:
Name Type Description filepathString File destination path
contentsString File new contents
callbackfunction 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:
-
Read its content from
fs - Compare it with the provided content
- If identical, mark it as is and skip the check
- If diverged, prepare and show up the file collision menu
Parameters:
Name Type Description fileObject File object respecting this interface: { path, contents }
cbfunction Callback receiving a status string ('identical', 'create', 'skip', 'force')
-
Read its content from
-
resolve (cb)
-
Process the potential conflict queue and ask the user to resolve conflict when they occur
The user is presented with the following options:
-
YYes, overwrite -
nNo, do not overwrite -
aAll, overwrite this and all others -
xExit, abort -
dDiff, show the differences between the old and the new -
hHelp, show this help
Parameters:
Name Type Description cbfunction Callback once every conflict are resolved. (note that each file can specify it's own callback. See
#checkForCollision()) -