{"id":15700046,"url":"https://github.com/jonschlinkert/conflicts","last_synced_at":"2025-05-12T13:09:26.110Z","repository":{"id":57205563,"uuid":"158674023","full_name":"jonschlinkert/conflicts","owner":"jonschlinkert","description":"Detects when a new file is different than an existing file and prompts the user for action.","archived":false,"fork":false,"pushed_at":"2018-12-17T05:00:19.000Z","size":431,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-12T13:08:55.539Z","etag":null,"topics":["conflict","conflicts","detect","file","file-system","files","fs","gulp","javascript","jonschlinkert","node","nodejs","prompt","vinyl","write"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-22T09:26:07.000Z","updated_at":"2021-04-12T22:22:10.000Z","dependencies_parsed_at":"2022-09-18T01:32:29.711Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/conflicts","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fconflicts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fconflicts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fconflicts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fconflicts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/conflicts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745160,"owners_count":21957317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conflict","conflicts","detect","file","file-system","files","fs","gulp","javascript","jonschlinkert","node","nodejs","prompt","vinyl","write"],"created_at":"2024-10-03T19:44:42.491Z","updated_at":"2025-05-12T13:09:26.002Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# conflicts [![NPM version](https://img.shields.io/npm/v/conflicts.svg?style=flat)](https://www.npmjs.com/package/conflicts) [![NPM monthly downloads](https://img.shields.io/npm/dm/conflicts.svg?style=flat)](https://npmjs.org/package/conflicts) [![NPM total downloads](https://img.shields.io/npm/dt/conflicts.svg?style=flat)](https://npmjs.org/package/conflicts) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/conflicts.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/conflicts)\n\n\u003e Detects when a new file is different than an existing file and prompts the user for action.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save conflicts\n```\n\n## Usage\n\n```js\nconst Conflicts = require('conflicts');\nconst conflicts = new Conflicts();\n```\n\n## API\n\n### [Conflicts](index.js#L26)\n\nCreate an instance of `Conflicts` with the given `options` and optional [Vinyl](https://github.com/gulpjs/vinyl) constructor.\n\n**Params**\n\n* `options` **{Object}**\n* `File` **{Function}**: Optionally pass a [vinyl](https://github.com/gulpjs/vinyl) contructor, otherwise the default `File` class is used.\n* `returns` **{Conflicts}**: Returns an instance of Conflicts.\n\n**Example**\n\n```js\nconst Conflicts = require('conflicts');\nconst conflicts = new Conflicts({}, require('vinyl'));\n```\n\n### [.detectFile](index.js#L60)\n\nCompares 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.\n\n**Params**\n\n* `proposedFile` **{Object}**: New file.\n* `existingFile` **{Object}**: Existing file.\n* `options` **{Object}**\n* `returns` **{Promise}**: Returns a promise with the action that was taken.\n\n**Example**\n\n```js\nconflicts.detect(fileA, fileB)\n  .then(action =\u003e console.log('Action taken:', action))\n  .catch(console.error)\n```\n\n### [.detectFile](index.js#L124)\n\nSame as [.detect](#detect), except the second argument is a string to an existing file on the file system.\n\n**Params**\n\n* `proposed` **{Object}**: New file.\n* `existingPath` **{Object}**: File path to existing file.\n* `options` **{Object}**\n* `returns` **{Promise}**: Returns a promise with the action that was taken.\n\n**Example**\n\n```js\nconflicts.detectFile(file, 'path/to/file.txt')\n  .then(action =\u003e console.log('Action taken:', action))\n  .catch(console.error)\n```\n\n### [.files](index.js#L145)\n\nRuns [detect](#detect) on an array of \"proposed\" files.\n\n**Params**\n\n* `files` **{Array}**: Array of file objects.\n* `options` **{Object}**\n* `returns` **{Array\u003cobject\u003e}**\n\n**Example**\n\n```js\nconflicts.files([fileA, fileB, fileC])\n  .then(action =\u003e console.log('Action taken:', action))\n  .catch(console.error)\n```\n\n### [.diffFiles](index.js#L186)\n\nTakes an array of \"proposed\" files, and returns an array of strings, where each string represents a [diff](https://github.com/kpdecker/jsdiff) of the proposed file's contents versus an existing file's contents.\n\n**Params**\n\n* `files` **{Array}**\n* `options` **{Object}**\n* `returns` **{Array\u003cstring\u003e}**\n\n**Example**\n\n```js\nconflicts.diffFiles([fileA, fileB, fileC])\n  .then(diffs =\u003e {\n    diffs.forEach(diff =\u003e console.log(diff));\n  })\n  .catch(console.error)\n```\n\n### [.isEqual](index.js#L233)\n\nReturns true if an `fileA` (existing/old) file appears to be identical to a `fileB` (proposed/new) file.\n\n**Params**\n\n* `proposed` **{Object}**: [vinyl](https://github.com/gulpjs/vinyl) file representing a proposed (new) file\n* `existing` **{Object}**: [vinyl](https://github.com/gulpjs/vinyl) file representing an existing (old) file\n* `options` **{Object}**\n* `returns` **{Boolean}**\n\n**Example**\n\n```js\nconsole.log(conflicts.isEqual(fileA, fileB));\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on December 08, 2018._","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fconflicts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fconflicts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fconflicts/lists"}