safe-merge-files
Merge two files like git
Install
npm install safe-merge-files
API
safeMergeFiles(oldFile, newFile[, options][, callback])
Content of oldFile
and newFile
will be merged and written into newFile
.
If conflict occurs, it will create git like merge conflict result which should be resolved manually. To resolve conflict automatically, use force
option.
oldFile
<string> Old filenamenewFile
<string> New filenameoptions
<object>callback
<Function>
safeMergeFiles.Sync(oldFile, newFile[, options])
Content of oldFile
and newFile
will be merged and written into newFile
.
If conflict occurs, it will create git like merge conflict result which should be resolved manually. To resolve conflict automatically, use force
option.
oldFile
<string> | <ReadStream> Old filename or a Readable StreamnewFile
<string> | <ReadStream> New filename or a Readable Streamoptions
<object>outputFile
<string> Defaults tonull
. If specified, the merged output will be written inoutputFile
instead ofnewFile
force
<boolean> Defaults tofalse
. If set totrue
, conflicts will be resolved by prefering new changes.stream
<boolean> Defaults tofalse
. If set to true, it returns a Readable Stream that can be consumed or piped.- Returns: <ReadStream> | <Integer>
If
options.stream
isfalse
, any of [0 = no change, 1 = no conflict, -1 = conflict] is returned.
Usage
Simple
var safeMergeFiles = ;
Force Apply Incoming Changes
var safeMergeFiles = ;
Sync
var safeMergeFiles = ; var stream= safeMergeFiles;var output=fs;stream;
Run Test
npm test