Fix path regex match bug (#3686)

* Fix path regex match bug

* Use the escape-string-regexp package to escape regex characters

* Remove redundant character escape from path

* Add removed escape of backslashes
This commit is contained in:
Norris Oduro
2018-01-04 18:15:50 +00:00
committed by Joe Haddad
parent 12120f6f55
commit 8cae659ec5

View File

@@ -8,12 +8,13 @@
'use strict';
const path = require('path');
const escape = require('escape-string-regexp');
module.exports = function ignoredFiles(appSrc) {
return new RegExp(
`^(?!${path
.normalize(appSrc + '/')
.replace(/[\\]+/g, '/')}).+/node_modules/`,
`^(?!${escape(
path.normalize(appSrc + '/').replace(/[\\]+/g, '/')
)}).+/node_modules/`,
'g'
);
};