Permalink
Browse files

Just do straight require of minimatch/utilities

  • Loading branch information...
mde
mde committed Aug 14, 2012
1 parent 500f7a3 commit d431deb73e43b0adef0e1bad06c2988d5cf7473e
Showing with 3 additions and 30 deletions.
  1. +3 −30 lib/file_list.js
View
@@ -17,7 +17,8 @@
*/
var fs = require('fs')
, path = require('path')
-, minimatch // Lazy-required
+, minimatch = require('minimatch')
+, utils = require('utilities')
, globSync;
globSync = function (pat) {
@@ -61,38 +62,10 @@ var ARRAY_METHODS = Object.getOwnPropertyNames(Array.prototype)
}
];
-// Utility methods
-// ---------------
-// Escapes special characters in a string to be used in generating
-// a regex
-var regexpEscape = (function() {
- var specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\' ]
- , sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
- return function (text) { return text.replace(sRE, '\\$1'); };
-})();
-
-
var FileList = function () {
var self = this
, wrap;
- // Lazy-require minimatch so that require of this file in cli.js won't bomb
- if (!minimatch) {
- try {
- minimatch = require('minimatch');
- }
- catch(e) {
- // Hacky fallback, assume global install at /usr/local?
- try {
- minimatch = require('/usr/local/lib/node_modules/minimatch');
- }
- catch(e) {
- fail('FileList requires minimatch ' +
- '(https://github.com/isaacs/minimatch). Try `npm install -g minimatch`.');
- }
- }
- }
-
// List of glob-patterns or specific filenames
this.pendingAdd = [];
// Switched to false after lazy-eval of files
@@ -171,7 +144,7 @@ FileList.prototype = new (function () {
}
// String for regex
else {
- excl.push(regexpEscape(pat));
+ excl.push(utils.string.escapeRegExpChars(pat));
}
}
// Regex, grab the string-representation

0 comments on commit d431deb

Please sign in to comment.