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:
parent
4b6b71664e
commit
977a40ed04
|
@ -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}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
Loading…
Reference in New Issue