Don’t error for known files that are reported as “added” by watchman

Reviewed By: tadeuzagallo

Differential Revision: D2696636

fb-gh-sync-id: 89f90aba2a22d9c3e93632df4c4bc01791525833
This commit is contained in:
David Aurelio 2015-11-26 05:33:38 -08:00 committed by facebook-github-bot-4
parent df5d178115
commit 882707ed13
2 changed files with 33 additions and 3 deletions

View File

@ -7,7 +7,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const path = require('path');
const getPlatformExtension = require('../lib/getPlatformExtension');
const Promise = require('promise');
@ -118,11 +117,12 @@ class HasteMap {
const moduleMap = this._map[name];
const modulePlatform = getPlatformExtension(mod.path) || GENERIC_PLATFORM;
const existingModule = moduleMap[modulePlatform];
if (moduleMap[modulePlatform]) {
if (existingModule && existingModule.path !== mod.path) {
throw new Error(
`Naming collision detected: ${mod.path} ` +
`collides with ${moduleMap[modulePlatform].path}`
`collides with ${existingModule.path}`
);
}

View File

@ -3821,6 +3821,36 @@ describe('DependencyGraph', function() {
});
});
});
pit('should not error when the watcher reports a known file as added', function() {
var root = '/root';
fs.__setMockFilesystem({
'root': {
'index.js': [
'/**',
' * @providesModule index',
' */',
'var b = require("b");',
].join('\n'),
'b.js': [
'/**',
' * @providesModule b',
' */',
'module.exports = function() {};',
].join('\n'),
},
});
var dgraph = new DependencyGraph({
...defaults,
roots: [root],
});
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function() {
triggerFileChange('add', 'index.js', root, mockStat);
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js');
});
});
});
describe('getAsyncDependencies', () => {