-
Notifications
You must be signed in to change notification settings - Fork 600
/
blacklist.js
46 lines (40 loc) 路 1.17 KB
/
blacklist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
var path = require('path');
// Don't forget to everything listed here to `package.json`
// modulePathIgnorePatterns.
var sharedBlacklist = [
/node_modules\/react\/dist\/.*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/,
];
function escapeRegExp(pattern) {
if (Object.prototype.toString.call(pattern) === '[object RegExp]') {
return pattern.source.replace(/\//g, path.sep);
} else if (typeof pattern === 'string') {
var escaped = pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
// convert the '/' into an escaped local file separator
return escaped.replace(/\//g, '\\' + path.sep);
} else {
throw new Error('Unexpected blacklist pattern: ' + pattern);
}
}
function blacklist(additionalBlacklist) {
return new RegExp(
'(' +
(additionalBlacklist || [])
.concat(sharedBlacklist)
.map(escapeRegExp)
.join('|') +
')$',
);
}
module.exports = blacklist;