Detects when a new file is different than an existing file and prompts the user for action.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save conflicts
const Conflicts = require('conflicts');
const conflicts = new Conflicts();
Create an instance of Conflicts with the given options and optional Vinyl constructor.
Params
options {Object}File {Function}: Optionally pass a vinyl contructor, otherwise the default File class is used.returns {Conflicts}: Returns an instance of Conflicts.Example
const Conflicts = require('conflicts');
const conflicts = new Conflicts({}, require('vinyl'));
Compares an existing (old) file to a new proposed file, then prompts for an action if the files are not equal. If the contents of both files is identical, no action is taken, otherwise you will be prompted to choose the action to take. See the unit tests for examples of how to skip prompts.
Params
proposedFile {Object}: New file.existingFile {Object}: Existing file.options {Object}returns {Promise}: Returns a promise with the action that was taken.Example
conflicts.detect(fileA, fileB)
.then(action => console.log('Action taken:', action))
.catch(console.error)
Same as .detect, except the second argument is a string to an existing file on the file system.
Params
proposed {Object}: New file.existingPath {Object}: File path to existing file.options {Object}returns {Promise}: Returns a promise with the action that was taken.Example
conflicts.detectFile(file, 'path/to/file.txt')
.then(action => console.log('Action taken:', action))
.catch(console.error)
Runs detect on an array of "proposed" files.
Params
files {Array}: Array of file objects.options {Object}returns {Array