first commit
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 0.8
|
||||
- 0.10
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
vow-fs [](http://badge.fury.io/js/vow-fs) [](http://travis-ci.org/dfilatov/vow-fs)
|
||||
======
|
||||
|
||||
[Vow](https://github.com/dfilatov/vow)-based file I/O for Node.js
|
||||
|
||||
Requirements
|
||||
------------
|
||||
Vow-fs works with Node.js 0.6, 0.8 and 0.10.
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
You can install vow-fs using Node Package Manager (npm):
|
||||
|
||||
npm install vow-fs
|
||||
|
||||
####Usage####
|
||||
````javascript
|
||||
var fs = require('vow-fs');
|
||||
````
|
||||
|
||||
API
|
||||
---
|
||||
####read(path, [encoding=utf8])####
|
||||
Returns a promise for the file's content at a given ````path````.
|
||||
####write(path, data, [encoding=utf8])####
|
||||
Writes ````data```` to file at a given ````path````. Returns a promise for the completion of the operation.
|
||||
####append(path, data, [encoding=utf8])####
|
||||
Appends````data```` to file's content at a given ````path````. Returns a promise for the completion of the operation.
|
||||
####remove(path)####
|
||||
Removes a file at a given ````path````. Returns a promise for the completion of the operation.
|
||||
####copy(sourcePath, targetPath)####
|
||||
Copies a file from ````sourcePath```` to ````targetPath````. Returns a promise for the completion of the operation.
|
||||
####move(sourcePath, targetPath)####
|
||||
Moves a file or directory from ````sourcePath```` to ````targetPath````. Returns a promise for the completion of the operation.
|
||||
####stat(path)####
|
||||
Returns a promise for the metadata about the given ````path```` as a [Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats) object.
|
||||
####exists(path)####
|
||||
Returns a promise for whether the given ````path```` exists.
|
||||
####link(sourcePath, targetPath)####
|
||||
Creates a hard link from the ````sourcePath```` to ````targetPath````.
|
||||
####symLink(sourcePath, targetPath, [type=file])####
|
||||
Creates a symbolic link from the ````sourcePath```` to ````targetPath````.
|
||||
####chown(path, uid, gid)####
|
||||
Changes the owner of a given ````path````.
|
||||
####chmod(path, mode)####
|
||||
Changes the mode of a given ````path```` to ````mode````.
|
||||
####absolute(path)####
|
||||
####isFile(path)####
|
||||
Returns a promise for whether the given ````path```` is a file.
|
||||
####isDir(path)####
|
||||
Returns a promise for whether the given ````path```` is a directory.
|
||||
####isSocket(path)####
|
||||
Returns a promise for whether the given ````path```` is a socket.
|
||||
####isSymLink(path)####
|
||||
Returns a promise for whether the given ````path```` is a symbolic link.
|
||||
####makeTmpFile([options])####
|
||||
Makes a temporary file. Returns a promise with generated path to file.
|
||||
The ````options````:
|
||||
* prefix (absent by default)
|
||||
* dir (operating system's directory for temp files by default)
|
||||
* ext (````.tmp```` by default)
|
||||
|
||||
####listDir(path)####
|
||||
Returns a promise for a list of files and directories in directory at the given ````path````.
|
||||
####makeDir(path, [mode=0777], [failIfExist=false])####
|
||||
Makes a directory at a given ````path```` and any necessary subdirectories (like ````mkdir -p````). Returns a promise for the completion of the operation.
|
||||
####removeDir(path)####
|
||||
Recursively removes a directory at a given path (like ````remove -rf````). Returns a promise for the completion of the operation.
|
||||
####glob(pattern, [options])####
|
||||
Matches files using the patterns. See https://github.com/isaacs/node-glob for details.
|
||||
+364
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @module vow-fs
|
||||
* @author Filatov Dmitry <dfilatov@yandex-team.ru>
|
||||
* @version 0.3.2
|
||||
* @license
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* * http://www.opensource.org/licenses/mit-license.php
|
||||
* * http://www.gnu.org/licenses/gpl.html
|
||||
*/
|
||||
|
||||
var vow = require('vow'),
|
||||
Queue = require('vow-queue'),
|
||||
openFilesQueue = new Queue(),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
os = require('os'),
|
||||
uuid = require('node-uuid'),
|
||||
glob = require('glob'),
|
||||
slice = Array.prototype.slice,
|
||||
promisify = function(nodeFn) {
|
||||
return function() {
|
||||
var defer = vow.defer(),
|
||||
args = slice.call(arguments);
|
||||
args.push(function(err) {
|
||||
err? defer.reject(err) : defer.resolve(arguments[1]);
|
||||
});
|
||||
try {
|
||||
nodeFn.apply(fs, args);
|
||||
}
|
||||
catch(err) {
|
||||
defer.reject(err);
|
||||
}
|
||||
return defer.promise();
|
||||
};
|
||||
},
|
||||
tmpDir = os.tmpdir || os.tmpDir || function() { return '/tmp'; },
|
||||
makeDir = promisify(fs.mkdir),
|
||||
removeDir = promisify(fs.rmdir),
|
||||
lstat = promisify(fs.lstat),
|
||||
emfileTimeout = 1,
|
||||
emfileFixWrapper = function(method, weight) {
|
||||
var wrapper = function() {
|
||||
var callArgs = arguments;
|
||||
return openFilesQueue.enqueue(function() {
|
||||
return method.apply(vfs, callArgs).then(
|
||||
function(res) {
|
||||
emfileTimeout = Math.max(1, emfileTimeout / 2);
|
||||
return res;
|
||||
},
|
||||
function(err) {
|
||||
if(err.code === 'EMFILE') {
|
||||
emfileTimeout++;
|
||||
return vow.delay(null, emfileTimeout).then(function() {
|
||||
return wrapper.apply(vfs, callArgs);
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}, weight);
|
||||
};
|
||||
return wrapper;
|
||||
},
|
||||
undef;
|
||||
|
||||
var vfs = module.exports = {
|
||||
/**
|
||||
* Reads file by given path
|
||||
* @param {String} path
|
||||
* @param {String} [encoding=utf8]
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
read : emfileFixWrapper(promisify(fs.readFile)),
|
||||
|
||||
/**
|
||||
* Writes data to file by given path
|
||||
* @param {String} path
|
||||
* @param {String|Buffer} data
|
||||
* @param {String} [encoding=utf8]
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
write : emfileFixWrapper(promisify(fs.writeFile)),
|
||||
|
||||
/**
|
||||
* Appends data to file by given path
|
||||
* @param {String} path
|
||||
* @param {String|Buffer} data
|
||||
* @param {String} [encoding=utf8]
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
append : emfileFixWrapper(promisify(fs.appendFile)),
|
||||
|
||||
/**
|
||||
* Removes file at given path
|
||||
* @param {String} pathToRemove
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
remove : promisify(fs.unlink),
|
||||
|
||||
/**
|
||||
* Copies file from sourcePath to targetPath
|
||||
* @param {String} sourcePath
|
||||
* @param {String} targetPath
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
copy : emfileFixWrapper(function(sourcePath, targetPath) {
|
||||
return this.isFile(sourcePath).then(function(isFile) {
|
||||
if(!isFile) {
|
||||
var err = Error();
|
||||
err.errno = 28;
|
||||
err.code = 'EISDIR';
|
||||
err.path = sourcePath;
|
||||
throw err;
|
||||
}
|
||||
|
||||
var defer = vow.defer(),
|
||||
sourceStream = fs.createReadStream(sourcePath),
|
||||
errFn = function(err) {
|
||||
defer.reject(err);
|
||||
};
|
||||
|
||||
sourceStream
|
||||
.on('error', errFn)
|
||||
.on('open', function() {
|
||||
var targetStream = fs.createWriteStream(targetPath);
|
||||
sourceStream.pipe(
|
||||
targetStream
|
||||
.on('error', errFn)
|
||||
.on('close', function() {
|
||||
defer.resolve();
|
||||
}));
|
||||
});
|
||||
|
||||
return defer.promise();
|
||||
});
|
||||
}, 2),
|
||||
|
||||
/**
|
||||
* Moves from sourcePath to targetPath
|
||||
* @param {String} sourcePath
|
||||
* @param {String} targetPath
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
move : promisify(fs.rename),
|
||||
|
||||
/**
|
||||
* Extracts fs.Stats about a given path
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
stat : promisify(fs.stat),
|
||||
|
||||
/**
|
||||
* Tests whether or not the given path exists
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
exists : fs.exists?
|
||||
function(path) {
|
||||
var defer = vow.defer();
|
||||
fs.exists(path, function(exists) {
|
||||
defer.resolve(exists);
|
||||
});
|
||||
return defer.promise();
|
||||
} :
|
||||
function(path) {
|
||||
var defer = vow.defer();
|
||||
fs.stat(path, function(err) {
|
||||
defer.resolve(!err);
|
||||
});
|
||||
return defer.promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a hard link from the sourcePath to targetPath
|
||||
* @param {String} sourcePath
|
||||
* @param {String} targetPath
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
link : promisify(fs.link),
|
||||
|
||||
/**
|
||||
* Creates a relative symbolic link from the sourcePath to targetPath
|
||||
* @param {String} sourcePath
|
||||
* @param {String} targetPath
|
||||
* @param {String} [type=file] can be either 'dir', 'file', or 'junction'
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
symLink : promisify(fs.symlink),
|
||||
|
||||
/**
|
||||
* Changes the owner for a given path using Unix user-id and group-id numbers
|
||||
* @param {String} path
|
||||
* @param uid
|
||||
* @param gid
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
chown : promisify(fs.chown),
|
||||
|
||||
/**
|
||||
* Changes the Unix mode for a path. Returns a promise
|
||||
* @param {String} path
|
||||
* @param mode
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
chmod : promisify(fs.chmod),
|
||||
|
||||
/**
|
||||
* Normalizes a given path to absolute path
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
absolute : promisify(fs.realpath),
|
||||
|
||||
/**
|
||||
* Checks whether the given path is a file
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
isFile : function(path) {
|
||||
return this.stat(path).then(function(stats) {
|
||||
return stats.isFile();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether the given path is a directory
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
isDir : function(path) {
|
||||
return this.stat(path).then(function(stats) {
|
||||
return stats.isDirectory();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether the given path is a socket
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
isSocket : function(path) {
|
||||
return this.stat(path).then(function(stats) {
|
||||
return stats.isSocket();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether the given path is a symbolic link
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
isSymLink : function(path) {
|
||||
return lstat(path).then(function(stats) {
|
||||
return stats.isSymbolicLink();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Makes a temporary file
|
||||
* @param {Object} options
|
||||
* @param {String} [options.prefix]
|
||||
* @param {String} [options.dir=os.tmpdir()]
|
||||
* @param {String} [options.ext=tmp]
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
makeTmpFile : function(options) {
|
||||
options || (options = {});
|
||||
|
||||
var filePath = path.join(
|
||||
options.dir || tmpDir(),
|
||||
(options.prefix || '') + uuid.v4() + (options.ext || '.tmp'));
|
||||
|
||||
return vfs.write(filePath, '').then(function() {
|
||||
return filePath;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Reads the contents of a directory by given path
|
||||
* @param {String} path
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
listDir : emfileFixWrapper(promisify(fs.readdir)),
|
||||
|
||||
/**
|
||||
* Makes a directory at a given path, recursively creating any branches that doesn't exist
|
||||
* @param {String} dirPath
|
||||
* @param [mode=0777]
|
||||
* @param [failIfExist=false]
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
makeDir : function(dirPath, mode, failIfExist) {
|
||||
if(typeof mode === 'boolean') {
|
||||
failIfExist = mode;
|
||||
mode = undef;
|
||||
}
|
||||
|
||||
var dirName = path.dirname(dirPath),
|
||||
onFailed = function(e) {
|
||||
if(e.code !== 'EEXIST' || failIfExist) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return vfs.isDir(dirPath).then(function(isDir) {
|
||||
if(!isDir) {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return vfs.exists(dirName).then(function(exists) {
|
||||
if(exists) {
|
||||
return makeDir(dirPath, mode).fail(onFailed);
|
||||
}
|
||||
else {
|
||||
failIfExist = false;
|
||||
return vfs.makeDir(dirName, mode).then(function() {
|
||||
return makeDir(dirPath, mode).fail(onFailed);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes directory
|
||||
* @param {String} dirPath
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
removeDir : function(dirPath) {
|
||||
return vfs.listDir(dirPath)
|
||||
.then(function(list) {
|
||||
return list.length && vow.all(
|
||||
list.map(function(file) {
|
||||
var fullPath = path.join(dirPath, file);
|
||||
return vfs.isFile(fullPath).then(function(isFile) {
|
||||
return isFile?
|
||||
vfs.remove(fullPath) :
|
||||
vfs.removeDir(fullPath);
|
||||
});
|
||||
}));
|
||||
})
|
||||
.then(function() {
|
||||
return removeDir(dirPath);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Matches files using the patterns, see https://github.com/isaacs/node-glob for details
|
||||
* @param {String} pattern to be matched
|
||||
* @param {Object} [options] options
|
||||
* @returns {vow:Promise}
|
||||
*/
|
||||
glob : promisify(glob),
|
||||
|
||||
options : function(opts) {
|
||||
if(typeof opts.openFileLimit !== 'undefined') {
|
||||
openFilesQueue.params({ weightLimit : opts.openFileLimit });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
openFilesQueue.start();
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
.*.swp
|
||||
test/a/
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
Copyright (c) Isaac Z. Schlueter ("Author")
|
||||
All rights reserved.
|
||||
|
||||
The BSD License
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
# Glob
|
||||
|
||||
Match files using the patterns the shell uses, like stars and stuff.
|
||||
|
||||
This is a glob implementation in JavaScript. It uses the `minimatch`
|
||||
library to do its matching.
|
||||
|
||||
## Attention: node-glob users!
|
||||
|
||||
The API has changed dramatically between 2.x and 3.x. This library is
|
||||
now 100% JavaScript, and the integer flags have been replaced with an
|
||||
options object.
|
||||
|
||||
Also, there's an event emitter class, proper tests, and all the other
|
||||
things you've come to expect from node modules.
|
||||
|
||||
And best of all, no compilation!
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var glob = require("glob")
|
||||
|
||||
// options is optional
|
||||
glob("**/*.js", options, function (er, files) {
|
||||
// files is an array of filenames.
|
||||
// If the `nonull` option is set, and nothing
|
||||
// was found, then files is ["**/*.js"]
|
||||
// er is an error object or null.
|
||||
})
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
Please see the [minimatch
|
||||
documentation](https://github.com/isaacs/minimatch) for more details.
|
||||
|
||||
Supports these glob features:
|
||||
|
||||
* Brace Expansion
|
||||
* Extended glob matching
|
||||
* "Globstar" `**` matching
|
||||
|
||||
See:
|
||||
|
||||
* `man sh`
|
||||
* `man bash`
|
||||
* `man 3 fnmatch`
|
||||
* `man 5 gitignore`
|
||||
* [minimatch documentation](https://github.com/isaacs/minimatch)
|
||||
|
||||
## glob(pattern, [options], cb)
|
||||
|
||||
* `pattern` {String} Pattern to be matched
|
||||
* `options` {Object}
|
||||
* `cb` {Function}
|
||||
* `err` {Error | null}
|
||||
* `matches` {Array<String>} filenames found matching the pattern
|
||||
|
||||
Perform an asynchronous glob search.
|
||||
|
||||
## glob.sync(pattern, [options])
|
||||
|
||||
* `pattern` {String} Pattern to be matched
|
||||
* `options` {Object}
|
||||
* return: {Array<String>} filenames found matching the pattern
|
||||
|
||||
Perform a synchronous glob search.
|
||||
|
||||
## Class: glob.Glob
|
||||
|
||||
Create a Glob object by instanting the `glob.Glob` class.
|
||||
|
||||
```javascript
|
||||
var Glob = require("glob").Glob
|
||||
var mg = new Glob(pattern, options, cb)
|
||||
```
|
||||
|
||||
It's an EventEmitter, and starts walking the filesystem to find matches
|
||||
immediately.
|
||||
|
||||
### new glob.Glob(pattern, [options], [cb])
|
||||
|
||||
* `pattern` {String} pattern to search for
|
||||
* `options` {Object}
|
||||
* `cb` {Function} Called when an error occurs, or matches are found
|
||||
* `err` {Error | null}
|
||||
* `matches` {Array<String>} filenames found matching the pattern
|
||||
|
||||
Note that if the `sync` flag is set in the options, then matches will
|
||||
be immediately available on the `g.found` member.
|
||||
|
||||
### Properties
|
||||
|
||||
* `minimatch` The minimatch object that the glob uses.
|
||||
* `options` The options object passed in.
|
||||
* `error` The error encountered. When an error is encountered, the
|
||||
glob object is in an undefined state, and should be discarded.
|
||||
* `aborted` Boolean which is set to true when calling `abort()`. There
|
||||
is no way at this time to continue a glob search after aborting, but
|
||||
you can re-use the statCache to avoid having to duplicate syscalls.
|
||||
* `statCache` Collection of all the stat results the glob search
|
||||
performed.
|
||||
* `cache` Convenience object. Each field has the following possible
|
||||
values:
|
||||
* `false` - Path does not exist
|
||||
* `true` - Path exists
|
||||
* `1` - Path exists, and is not a directory
|
||||
* `2` - Path exists, and is a directory
|
||||
* `[file, entries, ...]` - Path exists, is a directory, and the
|
||||
array value is the results of `fs.readdir`
|
||||
|
||||
### Events
|
||||
|
||||
* `end` When the matching is finished, this is emitted with all the
|
||||
matches found. If the `nonull` option is set, and no match was found,
|
||||
then the `matches` list contains the original pattern. The matches
|
||||
are sorted, unless the `nosort` flag is set.
|
||||
* `match` Every time a match is found, this is emitted with the matched.
|
||||
* `error` Emitted when an unexpected error is encountered, or whenever
|
||||
any fs error occurs if `options.strict` is set.
|
||||
* `abort` When `abort()` is called, this event is raised.
|
||||
|
||||
### Methods
|
||||
|
||||
* `abort` Stop the search.
|
||||
|
||||
### Options
|
||||
|
||||
All the options that can be passed to Minimatch can also be passed to
|
||||
Glob to change pattern matching behavior. Also, some have been added,
|
||||
or have glob-specific ramifications.
|
||||
|
||||
All options are false by default, unless otherwise noted.
|
||||
|
||||
All options are added to the glob object, as well.
|
||||
|
||||
* `cwd` The current working directory in which to search. Defaults
|
||||
to `process.cwd()`.
|
||||
* `root` The place where patterns starting with `/` will be mounted
|
||||
onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
|
||||
systems, and `C:\` or some such on Windows.)
|
||||
* `dot` Include `.dot` files in normal matches and `globstar` matches.
|
||||
Note that an explicit dot in a portion of the pattern will always
|
||||
match dot files.
|
||||
* `nomount` By default, a pattern starting with a forward-slash will be
|
||||
"mounted" onto the root setting, so that a valid filesystem path is
|
||||
returned. Set this flag to disable that behavior.
|
||||
* `mark` Add a `/` character to directory matches. Note that this
|
||||
requires additional stat calls.
|
||||
* `nosort` Don't sort the results.
|
||||
* `stat` Set to true to stat *all* results. This reduces performance
|
||||
somewhat, and is completely unnecessary, unless `readdir` is presumed
|
||||
to be an untrustworthy indicator of file existence. It will cause
|
||||
ELOOP to be triggered one level sooner in the case of cyclical
|
||||
symbolic links.
|
||||
* `silent` When an unusual error is encountered
|
||||
when attempting to read a directory, a warning will be printed to
|
||||
stderr. Set the `silent` option to true to suppress these warnings.
|
||||
* `strict` When an unusual error is encountered
|
||||
when attempting to read a directory, the process will just continue on
|
||||
in search of other matches. Set the `strict` option to raise an error
|
||||
in these cases.
|
||||
* `cache` See `cache` property above. Pass in a previously generated
|
||||
cache object to save some fs calls.
|
||||
* `statCache` A cache of results of filesystem information, to prevent
|
||||
unnecessary stat calls. While it should not normally be necessary to
|
||||
set this, you may pass the statCache from one glob() call to the
|
||||
options object of another, if you know that the filesystem will not
|
||||
change between calls. (See "Race Conditions" below.)
|
||||
* `sync` Perform a synchronous glob search.
|
||||
* `nounique` In some cases, brace-expanded patterns can result in the
|
||||
same file showing up multiple times in the result set. By default,
|
||||
this implementation prevents duplicates in the result set.
|
||||
Set this flag to disable that behavior.
|
||||
* `nonull` Set to never return an empty set, instead returning a set
|
||||
containing the pattern itself. This is the default in glob(3).
|
||||
* `nocase` Perform a case-insensitive match. Note that case-insensitive
|
||||
filesystems will sometimes result in glob returning results that are
|
||||
case-insensitively matched anyway, since readdir and stat will not
|
||||
raise an error.
|
||||
* `debug` Set to enable debug logging in minimatch and glob.
|
||||
* `globDebug` Set to enable debug logging in glob, but not minimatch.
|
||||
|
||||
## Comparisons to other fnmatch/glob implementations
|
||||
|
||||
While strict compliance with the existing standards is a worthwhile
|
||||
goal, some discrepancies exist between node-glob and other
|
||||
implementations, and are intentional.
|
||||
|
||||
If the pattern starts with a `!` character, then it is negated. Set the
|
||||
`nonegate` flag to suppress this behavior, and treat leading `!`
|
||||
characters normally. This is perhaps relevant if you wish to start the
|
||||
pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
|
||||
characters at the start of a pattern will negate the pattern multiple
|
||||
times.
|
||||
|
||||
If a pattern starts with `#`, then it is treated as a comment, and
|
||||
will not match anything. Use `\#` to match a literal `#` at the
|
||||
start of a line, or set the `nocomment` flag to suppress this behavior.
|
||||
|
||||
The double-star character `**` is supported by default, unless the
|
||||
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
||||
and bash 4.1, where `**` only has special significance if it is the only
|
||||
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
||||
`a/**b` will not.
|
||||
|
||||
If an escaped pattern has no matches, and the `nonull` flag is set,
|
||||
then glob returns the pattern as-provided, rather than
|
||||
interpreting the character escapes. For example,
|
||||
`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
||||
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
||||
that it does not resolve escaped pattern characters.
|
||||
|
||||
If brace expansion is not disabled, then it is performed before any
|
||||
other interpretation of the glob pattern. Thus, a pattern like
|
||||
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
||||
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
||||
checked for validity. Since those two are valid, matching proceeds.
|
||||
|
||||
## Windows
|
||||
|
||||
**Please only use forward-slashes in glob expressions.**
|
||||
|
||||
Though windows uses either `/` or `\` as its path separator, only `/`
|
||||
characters are used by this glob implementation. You must use
|
||||
forward-slashes **only** in glob expressions. Back-slashes will always
|
||||
be interpreted as escape characters, not path separators.
|
||||
|
||||
Results from absolute patterns such as `/foo/*` are mounted onto the
|
||||
root setting using `path.join`. On windows, this will by default result
|
||||
in `/foo/*` matching `C:\foo\bar.txt`.
|
||||
|
||||
## Race Conditions
|
||||
|
||||
Glob searching, by its very nature, is susceptible to race conditions,
|
||||
since it relies on directory walking and such.
|
||||
|
||||
As a result, it is possible that a file that exists when glob looks for
|
||||
it may have been deleted or modified by the time it returns the result.
|
||||
|
||||
As part of its internal implementation, this program caches all stat
|
||||
and readdir calls that it makes, in order to cut down on system
|
||||
overhead. However, this also makes it even more susceptible to races,
|
||||
especially if the cache or statCache objects are reused between glob
|
||||
calls.
|
||||
|
||||
Users are thus advised not to use a glob result as a guarantee of
|
||||
filesystem state in the face of rapid changes. For the vast majority
|
||||
of operations, this is never a problem.
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
var Glob = require("../").Glob
|
||||
|
||||
var pattern = "test/a/**/[cg]/../[cg]"
|
||||
console.log(pattern)
|
||||
|
||||
var mg = new Glob(pattern, {mark: true, sync:true}, function (er, matches) {
|
||||
console.log("matches", matches)
|
||||
})
|
||||
console.log("after")
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
var Glob = require("../").Glob
|
||||
|
||||
var pattern = "{./*/*,/*,/usr/local/*}"
|
||||
console.log(pattern)
|
||||
|
||||
var mg = new Glob(pattern, {mark: true}, function (er, matches) {
|
||||
console.log("matches", matches)
|
||||
})
|
||||
console.log("after")
|
||||
+690
@@ -0,0 +1,690 @@
|
||||
// Approach:
|
||||
//
|
||||
// 1. Get the minimatch set
|
||||
// 2. For each pattern in the set, PROCESS(pattern)
|
||||
// 3. Store matches per-set, then uniq them
|
||||
//
|
||||
// PROCESS(pattern)
|
||||
// Get the first [n] items from pattern that are all strings
|
||||
// Join these together. This is PREFIX.
|
||||
// If there is no more remaining, then stat(PREFIX) and
|
||||
// add to matches if it succeeds. END.
|
||||
// readdir(PREFIX) as ENTRIES
|
||||
// If fails, END
|
||||
// If pattern[n] is GLOBSTAR
|
||||
// // handle the case where the globstar match is empty
|
||||
// // by pruning it out, and testing the resulting pattern
|
||||
// PROCESS(pattern[0..n] + pattern[n+1 .. $])
|
||||
// // handle other cases.
|
||||
// for ENTRY in ENTRIES (not dotfiles)
|
||||
// // attach globstar + tail onto the entry
|
||||
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $])
|
||||
//
|
||||
// else // not globstar
|
||||
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
|
||||
// Test ENTRY against pattern[n]
|
||||
// If fails, continue
|
||||
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
|
||||
//
|
||||
// Caveat:
|
||||
// Cache all stats and readdirs results to minimize syscall. Since all
|
||||
// we ever care about is existence and directory-ness, we can just keep
|
||||
// `true` for files, and [children,...] for directories, or `false` for
|
||||
// things that don't exist.
|
||||
|
||||
|
||||
|
||||
module.exports = glob
|
||||
|
||||
var fs = require("fs")
|
||||
, minimatch = require("minimatch")
|
||||
, Minimatch = minimatch.Minimatch
|
||||
, inherits = require("inherits")
|
||||
, EE = require("events").EventEmitter
|
||||
, path = require("path")
|
||||
, isDir = {}
|
||||
, assert = require("assert").ok
|
||||
|
||||
function glob (pattern, options, cb) {
|
||||
if (typeof options === "function") cb = options, options = {}
|
||||
if (!options) options = {}
|
||||
|
||||
if (typeof options === "number") {
|
||||
deprecated()
|
||||
return
|
||||
}
|
||||
|
||||
var g = new Glob(pattern, options, cb)
|
||||
return g.sync ? g.found : g
|
||||
}
|
||||
|
||||
glob.fnmatch = deprecated
|
||||
|
||||
function deprecated () {
|
||||
throw new Error("glob's interface has changed. Please see the docs.")
|
||||
}
|
||||
|
||||
glob.sync = globSync
|
||||
function globSync (pattern, options) {
|
||||
if (typeof options === "number") {
|
||||
deprecated()
|
||||
return
|
||||
}
|
||||
|
||||
options = options || {}
|
||||
options.sync = true
|
||||
return glob(pattern, options)
|
||||
}
|
||||
|
||||
|
||||
glob.Glob = Glob
|
||||
inherits(Glob, EE)
|
||||
function Glob (pattern, options, cb) {
|
||||
if (!(this instanceof Glob)) {
|
||||
return new Glob(pattern, options, cb)
|
||||
}
|
||||
|
||||
if (typeof options === "function") {
|
||||
cb = options
|
||||
options = null
|
||||
}
|
||||
|
||||
if (typeof cb === "function") {
|
||||
this.on("error", cb)
|
||||
this.on("end", function (matches) {
|
||||
cb(null, matches)
|
||||
})
|
||||
}
|
||||
|
||||
options = options || {}
|
||||
|
||||
this.EOF = {}
|
||||
this._emitQueue = []
|
||||
|
||||
this.maxDepth = options.maxDepth || 1000
|
||||
this.maxLength = options.maxLength || Infinity
|
||||
this.cache = options.cache || {}
|
||||
this.statCache = options.statCache || {}
|
||||
|
||||
this.changedCwd = false
|
||||
var cwd = process.cwd()
|
||||
if (!options.hasOwnProperty("cwd")) this.cwd = cwd
|
||||
else {
|
||||
this.cwd = options.cwd
|
||||
this.changedCwd = path.resolve(options.cwd) !== cwd
|
||||
}
|
||||
|
||||
this.root = options.root || path.resolve(this.cwd, "/")
|
||||
this.root = path.resolve(this.root)
|
||||
if (process.platform === "win32")
|
||||
this.root = this.root.replace(/\\/g, "/")
|
||||
|
||||
this.nomount = !!options.nomount
|
||||
|
||||
if (!pattern) {
|
||||
throw new Error("must provide pattern")
|
||||
}
|
||||
|
||||
// base-matching: just use globstar for that.
|
||||
if (options.matchBase && -1 === pattern.indexOf("/")) {
|
||||
if (options.noglobstar) {
|
||||
throw new Error("base matching requires globstar")
|
||||
}
|
||||
pattern = "**/" + pattern
|
||||
}
|
||||
|
||||
this.strict = options.strict !== false
|
||||
this.dot = !!options.dot
|
||||
this.mark = !!options.mark
|
||||
this.sync = !!options.sync
|
||||
this.nounique = !!options.nounique
|
||||
this.nonull = !!options.nonull
|
||||
this.nosort = !!options.nosort
|
||||
this.nocase = !!options.nocase
|
||||
this.stat = !!options.stat
|
||||
|
||||
this.debug = !!options.debug || !!options.globDebug
|
||||
if (this.debug)
|
||||
this.log = console.error
|
||||
|
||||
this.silent = !!options.silent
|
||||
|
||||
var mm = this.minimatch = new Minimatch(pattern, options)
|
||||
this.options = mm.options
|
||||
pattern = this.pattern = mm.pattern
|
||||
|
||||
this.error = null
|
||||
this.aborted = false
|
||||
|
||||
// list of all the patterns that ** has resolved do, so
|
||||
// we can avoid visiting multiple times.
|
||||
this._globstars = {}
|
||||
|
||||
EE.call(this)
|
||||
|
||||
// process each pattern in the minimatch set
|
||||
var n = this.minimatch.set.length
|
||||
|
||||
// The matches are stored as {<filename>: true,...} so that
|
||||
// duplicates are automagically pruned.
|
||||
// Later, we do an Object.keys() on these.
|
||||
// Keep them as a list so we can fill in when nonull is set.
|
||||
this.matches = new Array(n)
|
||||
|
||||
this.minimatch.set.forEach(iterator.bind(this))
|
||||
function iterator (pattern, i, set) {
|
||||
this._process(pattern, 0, i, function (er) {
|
||||
if (er) this.emit("error", er)
|
||||
if (-- n <= 0) this._finish()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype.log = function () {}
|
||||
|
||||
Glob.prototype._finish = function () {
|
||||
assert(this instanceof Glob)
|
||||
|
||||
var nou = this.nounique
|
||||
, all = nou ? [] : {}
|
||||
|
||||
for (var i = 0, l = this.matches.length; i < l; i ++) {
|
||||
var matches = this.matches[i]
|
||||
this.log("matches[%d] =", i, matches)
|
||||
// do like the shell, and spit out the literal glob
|
||||
if (!matches) {
|
||||
if (this.nonull) {
|
||||
var literal = this.minimatch.globSet[i]
|
||||
if (nou) all.push(literal)
|
||||
else all[literal] = true
|
||||
}
|
||||
} else {
|
||||
// had matches
|
||||
var m = Object.keys(matches)
|
||||
if (nou) all.push.apply(all, m)
|
||||
else m.forEach(function (m) {
|
||||
all[m] = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!nou) all = Object.keys(all)
|
||||
|
||||
if (!this.nosort) {
|
||||
all = all.sort(this.nocase ? alphasorti : alphasort)
|
||||
}
|
||||
|
||||
this.log("emitting end", all)
|
||||
|
||||
this.EOF = this.found = all
|
||||
this.emitMatch(this.EOF, -1)
|
||||
}
|
||||
|
||||
function alphasorti (a, b) {
|
||||
a = a.toLowerCase()
|
||||
b = b.toLowerCase()
|
||||
return alphasort(a, b)
|
||||
}
|
||||
|
||||
function alphasort (a, b) {
|
||||
return a > b ? 1 : a < b ? -1 : 0
|
||||
}
|
||||
|
||||
Glob.prototype.abort = function () {
|
||||
this.aborted = true
|
||||
this.emit("abort")
|
||||
}
|
||||
|
||||
Glob.prototype.pause = function () {
|
||||
if (this.paused) return
|
||||
if (this.sync)
|
||||
this.emit("error", new Error("Can't pause/resume sync glob"))
|
||||
this.paused = true
|
||||
this.emit("pause")
|
||||
}
|
||||
|
||||
Glob.prototype.resume = function () {
|
||||
if (!this.paused) return
|
||||
if (this.sync)
|
||||
this.emit("error", new Error("Can't pause/resume sync glob"))
|
||||
this.paused = false
|
||||
this.emit("resume")
|
||||
this._processEmitQueue()
|
||||
//process.nextTick(this.emit.bind(this, "resume"))
|
||||
}
|
||||
|
||||
Glob.prototype._mark = function (p) {
|
||||
var c = this.cache[p]
|
||||
var m = p
|
||||
if (c) {
|
||||
var isDir = c === 2 || Array.isArray(c)
|
||||
var slash = p.slice(-1) === '/'
|
||||
|
||||
if (isDir && !slash)
|
||||
m += '/'
|
||||
else if (!isDir && slash)
|
||||
m = m.slice(0, -1)
|
||||
|
||||
if (m !== p) {
|
||||
this.statCache[m] = this.statCache[p]
|
||||
this.cache[m] = this.cache[p]
|
||||
}
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
Glob.prototype._pushMatch = function(m, index) {
|
||||
if (this.mark && m !== this.EOF)
|
||||
m = this._mark(m)
|
||||
|
||||
if (m !== this.EOF) {
|
||||
this.matches[index] = this.matches[index] || {}
|
||||
this.matches[index][m] = true
|
||||
}
|
||||
|
||||
this._emitQueue.push(m)
|
||||
this._processEmitQueue()
|
||||
}
|
||||
|
||||
Glob.prototype.emitMatch = function (m, index) {
|
||||
if ((!this.stat && !this.mark) || this.statCache[m] || m === this.EOF) {
|
||||
this._pushMatch(m, index)
|
||||
} else {
|
||||
this._stat(m, function(exists, isDir) {
|
||||
if (exists)
|
||||
this._pushMatch(m, index)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._processEmitQueue = function (m) {
|
||||
while (!this._processingEmitQueue &&
|
||||
!this.paused) {
|
||||
this._processingEmitQueue = true
|
||||
var m = this._emitQueue.shift()
|
||||
if (!m) {
|
||||
this._processingEmitQueue = false
|
||||
break
|
||||
}
|
||||
|
||||
this.log('emit!', m === this.EOF ? "end" : "match")
|
||||
|
||||
this.emit(m === this.EOF ? "end" : "match", m)
|
||||
this._processingEmitQueue = false
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._process = function (pattern, depth, index, cb_) {
|
||||
assert(this instanceof Glob)
|
||||
|
||||
var cb = function cb (er, res) {
|
||||
assert(this instanceof Glob)
|
||||
if (this.paused) {
|
||||
if (!this._processQueue) {
|
||||
this._processQueue = []
|
||||
this.once("resume", function () {
|
||||
var q = this._processQueue
|
||||
this._processQueue = null
|
||||
q.forEach(function (cb) { cb() })
|
||||
})
|
||||
}
|
||||
this._processQueue.push(cb_.bind(this, er, res))
|
||||
} else {
|
||||
cb_.call(this, er, res)
|
||||
}
|
||||
}.bind(this)
|
||||
|
||||
if (this.aborted) return cb()
|
||||
|
||||
if (depth > this.maxDepth) return cb()
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === "string") {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// see if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
prefix = pattern.join("/")
|
||||
this._stat(prefix, function (exists, isDir) {
|
||||
// either it's there, or it isn't.
|
||||
// nothing more to do, either way.
|
||||
if (exists) {
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
if (prefix.charAt(0) === "/") {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === "win32")
|
||||
prefix = prefix.replace(/\\/g, "/")
|
||||
|
||||
this.emitMatch(prefix, index)
|
||||
}
|
||||
return cb()
|
||||
})
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's "absolute" like /foo/bar,
|
||||
// or "relative" like "../baz"
|
||||
prefix = pattern.slice(0, n)
|
||||
prefix = prefix.join("/")
|
||||
break
|
||||
}
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null) read = "."
|
||||
else if (isAbsolute(prefix) || isAbsolute(pattern.join("/"))) {
|
||||
if (!prefix || !isAbsolute(prefix)) {
|
||||
prefix = path.join("/", prefix)
|
||||
}
|
||||
read = prefix = path.resolve(prefix)
|
||||
|
||||
// if (process.platform === "win32")
|
||||
// read = prefix = prefix.replace(/^[a-zA-Z]:|\\/g, "/")
|
||||
|
||||
this.log('absolute: ', prefix, this.root, pattern, read)
|
||||
} else {
|
||||
read = prefix
|
||||
}
|
||||
|
||||
this.log('readdir(%j)', read, this.cwd, this.root)
|
||||
|
||||
return this._readdir(read, function (er, entries) {
|
||||
if (er) {
|
||||
// not a directory!
|
||||
// this means that, whatever else comes after this, it can never match
|
||||
return cb()
|
||||
}
|
||||
|
||||
// globstar is special
|
||||
if (pattern[n] === minimatch.GLOBSTAR) {
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var s = [ pattern.slice(0, n).concat(pattern.slice(n + 1)) ]
|
||||
entries.forEach(function (e) {
|
||||
if (e.charAt(0) === "." && !this.dot) return
|
||||
// instead of the globstar
|
||||
s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1)))
|
||||
// below the globstar
|
||||
s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n)))
|
||||
}, this)
|
||||
|
||||
s = s.filter(function (pattern) {
|
||||
var key = gsKey(pattern)
|
||||
var seen = !this._globstars[key]
|
||||
this._globstars[key] = true
|
||||
return seen
|
||||
}, this)
|
||||
|
||||
if (!s.length)
|
||||
return cb()
|
||||
|
||||
// now asyncForEach over this
|
||||
var l = s.length
|
||||
, errState = null
|
||||
s.forEach(function (gsPattern) {
|
||||
this._process(gsPattern, depth + 1, index, function (er) {
|
||||
if (errState) return
|
||||
if (er) return cb(errState = er)
|
||||
if (--l <= 0) return cb()
|
||||
})
|
||||
}, this)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// not a globstar
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = pattern[n]
|
||||
var rawGlob = pattern[n]._glob
|
||||
, dotOk = this.dot || rawGlob.charAt(0) === "."
|
||||
|
||||
entries = entries.filter(function (e) {
|
||||
return (e.charAt(0) !== "." || dotOk) &&
|
||||
e.match(pattern[n])
|
||||
})
|
||||
|
||||
// If n === pattern.length - 1, then there's no need for the extra stat
|
||||
// *unless* the user has specified "mark" or "stat" explicitly.
|
||||
// We know that they exist, since the readdir returned them.
|
||||
if (n === pattern.length - 1 &&
|
||||
!this.mark &&
|
||||
!this.stat) {
|
||||
entries.forEach(function (e) {
|
||||
if (prefix) {
|
||||
if (prefix !== "/") e = prefix + "/" + e
|
||||
else e = prefix + e
|
||||
}
|
||||
if (e.charAt(0) === "/" && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
|
||||
if (process.platform === "win32")
|
||||
e = e.replace(/\\/g, "/")
|
||||
|
||||
this.emitMatch(e, index)
|
||||
}, this)
|
||||
return cb.call(this)
|
||||
}
|
||||
|
||||
|
||||
// now test all the remaining entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
var l = entries.length
|
||||
, errState = null
|
||||
if (l === 0) return cb() // no matches possible
|
||||
entries.forEach(function (e) {
|
||||
var p = pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1))
|
||||
this._process(p, depth + 1, index, function (er) {
|
||||
if (errState) return
|
||||
if (er) return cb(errState = er)
|
||||
if (--l === 0) return cb.call(this)
|
||||
})
|
||||
}, this)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function gsKey (pattern) {
|
||||
return '**' + pattern.map(function (p) {
|
||||
return (p === minimatch.GLOBSTAR) ? '**' : (''+p)
|
||||
}).join('/')
|
||||
}
|
||||
|
||||
Glob.prototype._stat = function (f, cb) {
|
||||
assert(this instanceof Glob)
|
||||
var abs = f
|
||||
if (f.charAt(0) === "/") {
|
||||
abs = path.join(this.root, f)
|
||||
} else if (this.changedCwd) {
|
||||
abs = path.resolve(this.cwd, f)
|
||||
}
|
||||
|
||||
if (f.length > this.maxLength) {
|
||||
var er = new Error("Path name too long")
|
||||
er.code = "ENAMETOOLONG"
|
||||
er.path = f
|
||||
return this._afterStat(f, abs, cb, er)
|
||||
}
|
||||
|
||||
this.log('stat', [this.cwd, f, '=', abs])
|
||||
|
||||
if (!this.stat && this.cache.hasOwnProperty(f)) {
|
||||
var exists = this.cache[f]
|
||||
, isDir = exists && (Array.isArray(exists) || exists === 2)
|
||||
if (this.sync) return cb.call(this, !!exists, isDir)
|
||||
return process.nextTick(cb.bind(this, !!exists, isDir))
|
||||
}
|
||||
|
||||
var stat = this.statCache[abs]
|
||||
if (this.sync || stat) {
|
||||
var er
|
||||
try {
|
||||
stat = fs.statSync(abs)
|
||||
} catch (e) {
|
||||
er = e
|
||||
}
|
||||
this._afterStat(f, abs, cb, er, stat)
|
||||
} else {
|
||||
fs.stat(abs, this._afterStat.bind(this, f, abs, cb))
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._afterStat = function (f, abs, cb, er, stat) {
|
||||
var exists
|
||||
assert(this instanceof Glob)
|
||||
|
||||
if (abs.slice(-1) === "/" && stat && !stat.isDirectory()) {
|
||||
this.log("should be ENOTDIR, fake it")
|
||||
|
||||
er = new Error("ENOTDIR, not a directory '" + abs + "'")
|
||||
er.path = abs
|
||||
er.code = "ENOTDIR"
|
||||
stat = null
|
||||
}
|
||||
|
||||
var emit = !this.statCache[abs]
|
||||
this.statCache[abs] = stat
|
||||
|
||||
if (er || !stat) {
|
||||
exists = false
|
||||
} else {
|
||||
exists = stat.isDirectory() ? 2 : 1
|
||||
if (emit)
|
||||
this.emit('stat', f, stat)
|
||||
}
|
||||
this.cache[f] = this.cache[f] || exists
|
||||
cb.call(this, !!exists, exists === 2)
|
||||
}
|
||||
|
||||
Glob.prototype._readdir = function (f, cb) {
|
||||
assert(this instanceof Glob)
|
||||
var abs = f
|
||||
if (f.charAt(0) === "/") {
|
||||
abs = path.join(this.root, f)
|
||||
} else if (isAbsolute(f)) {
|
||||
abs = f
|
||||
} else if (this.changedCwd) {
|
||||
abs = path.resolve(this.cwd, f)
|
||||
}
|
||||
|
||||
if (f.length > this.maxLength) {
|
||||
var er = new Error("Path name too long")
|
||||
er.code = "ENAMETOOLONG"
|
||||
er.path = f
|
||||
return this._afterReaddir(f, abs, cb, er)
|
||||
}
|
||||
|
||||
this.log('readdir', [this.cwd, f, abs])
|
||||
if (this.cache.hasOwnProperty(f)) {
|
||||
var c = this.cache[f]
|
||||
if (Array.isArray(c)) {
|
||||
if (this.sync) return cb.call(this, null, c)
|
||||
return process.nextTick(cb.bind(this, null, c))
|
||||
}
|
||||
|
||||
if (!c || c === 1) {
|
||||
// either ENOENT or ENOTDIR
|
||||
var code = c ? "ENOTDIR" : "ENOENT"
|
||||
, er = new Error((c ? "Not a directory" : "Not found") + ": " + f)
|
||||
er.path = f
|
||||
er.code = code
|
||||
this.log(f, er)
|
||||
if (this.sync) return cb.call(this, er)
|
||||
return process.nextTick(cb.bind(this, er))
|
||||
}
|
||||
|
||||
// at this point, c === 2, meaning it's a dir, but we haven't
|
||||
// had to read it yet, or c === true, meaning it's *something*
|
||||
// but we don't have any idea what. Need to read it, either way.
|
||||
}
|
||||
|
||||
if (this.sync) {
|
||||
var er, entries
|
||||
try {
|
||||
entries = fs.readdirSync(abs)
|
||||
} catch (e) {
|
||||
er = e
|
||||
}
|
||||
return this._afterReaddir(f, abs, cb, er, entries)
|
||||
}
|
||||
|
||||
fs.readdir(abs, this._afterReaddir.bind(this, f, abs, cb))
|
||||
}
|
||||
|
||||
Glob.prototype._afterReaddir = function (f, abs, cb, er, entries) {
|
||||
assert(this instanceof Glob)
|
||||
if (entries && !er) {
|
||||
this.cache[f] = entries
|
||||
// if we haven't asked to stat everything for suresies, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time. This also gets us one step
|
||||
// further into ELOOP territory.
|
||||
if (!this.mark && !this.stat) {
|
||||
entries.forEach(function (e) {
|
||||
if (f === "/") e = f + e
|
||||
else e = f + "/" + e
|
||||
this.cache[e] = true
|
||||
}, this)
|
||||
}
|
||||
|
||||
return cb.call(this, er, entries)
|
||||
}
|
||||
|
||||
// now handle errors, and cache the information
|
||||
if (er) switch (er.code) {
|
||||
case "ENOTDIR": // totally normal. means it *does* exist.
|
||||
this.cache[f] = 1
|
||||
return cb.call(this, er)
|
||||
case "ENOENT": // not terribly unusual
|
||||
case "ELOOP":
|
||||
case "ENAMETOOLONG":
|
||||
case "UNKNOWN":
|
||||
this.cache[f] = false
|
||||
return cb.call(this, er)
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[f] = false
|
||||
if (this.strict) this.emit("error", er)
|
||||
if (!this.silent) console.error("glob error", er)
|
||||
return cb.call(this, er)
|
||||
}
|
||||
}
|
||||
|
||||
var isAbsolute = process.platform === "win32" ? absWin : absUnix
|
||||
|
||||
function absWin (p) {
|
||||
if (absUnix(p)) return true
|
||||
// pull off the device/UNC bit from a windows path.
|
||||
// from node's lib/path.js
|
||||
var splitDeviceRe =
|
||||
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/
|
||||
, result = splitDeviceRe.exec(p)
|
||||
, device = result[1] || ''
|
||||
, isUnc = device && device.charAt(1) !== ':'
|
||||
, isAbsolute = !!result[2] || isUnc // UNC paths are always absolute
|
||||
|
||||
return isAbsolute
|
||||
}
|
||||
|
||||
function absUnix (p) {
|
||||
return p.charAt(0) === "/" || p === ""
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"glob@3.2.8",
|
||||
"/mnt/data/Sites/r2c.net/user/themes/r2c"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "glob@3.2.8",
|
||||
"_id": "glob@3.2.8",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-VQb0MRchvMYYx9jboUQYh1AwcHM=",
|
||||
"_location": "/vow-fs/glob",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "glob@3.2.8",
|
||||
"name": "glob",
|
||||
"escapedName": "glob",
|
||||
"rawSpec": "3.2.8",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.2.8"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vow-fs"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/glob/-/glob-3.2.8.tgz",
|
||||
"_spec": "3.2.8",
|
||||
"_where": "/mnt/data/Sites/r2c.net/user/themes/r2c",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-glob/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"inherits": "2",
|
||||
"minimatch": "~0.2.11"
|
||||
},
|
||||
"description": "a little globber",
|
||||
"devDependencies": {
|
||||
"mkdirp": "0",
|
||||
"rimraf": "1",
|
||||
"tap": "~0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/isaacs/node-glob#readme",
|
||||
"license": "BSD",
|
||||
"main": "glob.js",
|
||||
"name": "glob",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/node-glob.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "3.2.8"
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
// just a little pre-run script to set up the fixtures.
|
||||
// zz-finish cleans it up
|
||||
|
||||
var mkdirp = require("mkdirp")
|
||||
var path = require("path")
|
||||
var i = 0
|
||||
var tap = require("tap")
|
||||
var fs = require("fs")
|
||||
var rimraf = require("rimraf")
|
||||
|
||||
var files =
|
||||
[ "a/.abcdef/x/y/z/a"
|
||||
, "a/abcdef/g/h"
|
||||
, "a/abcfed/g/h"
|
||||
, "a/b/c/d"
|
||||
, "a/bc/e/f"
|
||||
, "a/c/d/c/b"
|
||||
, "a/cb/e/f"
|
||||
]
|
||||
|
||||
var symlinkTo = path.resolve(__dirname, "a/symlink/a/b/c")
|
||||
var symlinkFrom = "../.."
|
||||
|
||||
files = files.map(function (f) {
|
||||
return path.resolve(__dirname, f)
|
||||
})
|
||||
|
||||
tap.test("remove fixtures", function (t) {
|
||||
rimraf(path.resolve(__dirname, "a"), function (er) {
|
||||
t.ifError(er, "remove fixtures")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
files.forEach(function (f) {
|
||||
tap.test(f, function (t) {
|
||||
var d = path.dirname(f)
|
||||
mkdirp(d, 0755, function (er) {
|
||||
if (er) {
|
||||
t.fail(er)
|
||||
return t.bailout()
|
||||
}
|
||||
fs.writeFile(f, "i like tests", function (er) {
|
||||
t.ifError(er, "make file")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
if (process.platform !== "win32") {
|
||||
tap.test("symlinky", function (t) {
|
||||
var d = path.dirname(symlinkTo)
|
||||
console.error("mkdirp", d)
|
||||
mkdirp(d, 0755, function (er) {
|
||||
t.ifError(er)
|
||||
fs.symlink(symlinkFrom, symlinkTo, "dir", function (er) {
|
||||
t.ifError(er, "make symlink")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
;["foo","bar","baz","asdf","quux","qwer","rewq"].forEach(function (w) {
|
||||
w = "/tmp/glob-test/" + w
|
||||
tap.test("create " + w, function (t) {
|
||||
mkdirp(w, function (er) {
|
||||
if (er)
|
||||
throw er
|
||||
t.pass(w)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// generate the bash pattern test-fixtures if possible
|
||||
if (process.platform === "win32" || !process.env.TEST_REGEN) {
|
||||
console.error("Windows, or TEST_REGEN unset. Using cached fixtures.")
|
||||
return
|
||||
}
|
||||
|
||||
var spawn = require("child_process").spawn;
|
||||
var globs =
|
||||
// put more patterns here.
|
||||
// anything that would be directly in / should be in /tmp/glob-test
|
||||
["test/a/*/+(c|g)/./d"
|
||||
,"test/a/**/[cg]/../[cg]"
|
||||
,"test/a/{b,c,d,e,f}/**/g"
|
||||
,"test/a/b/**"
|
||||
,"test/**/g"
|
||||
,"test/a/abc{fed,def}/g/h"
|
||||
,"test/a/abc{fed/g,def}/**/"
|
||||
,"test/a/abc{fed/g,def}/**///**/"
|
||||
,"test/**/a/**/"
|
||||
,"test/+(a|b|c)/a{/,bc*}/**"
|
||||
,"test/*/*/*/f"
|
||||
,"test/**/f"
|
||||
,"test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**"
|
||||
,"{./*/*,/tmp/glob-test/*}"
|
||||
,"{/tmp/glob-test/*,*}" // evil owl face! how you taunt me!
|
||||
,"test/a/!(symlink)/**"
|
||||
]
|
||||
var bashOutput = {}
|
||||
var fs = require("fs")
|
||||
|
||||
globs.forEach(function (pattern) {
|
||||
tap.test("generate fixture " + pattern, function (t) {
|
||||
var cmd = "shopt -s globstar && " +
|
||||
"shopt -s extglob && " +
|
||||
"shopt -s nullglob && " +
|
||||
// "shopt >&2; " +
|
||||
"eval \'for i in " + pattern + "; do echo $i; done\'"
|
||||
var cp = spawn("bash", ["-c", cmd], { cwd: path.dirname(__dirname) })
|
||||
var out = []
|
||||
cp.stdout.on("data", function (c) {
|
||||
out.push(c)
|
||||
})
|
||||
cp.stderr.pipe(process.stderr)
|
||||
cp.on("close", function (code) {
|
||||
out = flatten(out)
|
||||
if (!out)
|
||||
out = []
|
||||
else
|
||||
out = cleanResults(out.split(/\r*\n/))
|
||||
|
||||
bashOutput[pattern] = out
|
||||
t.notOk(code, "bash test should finish nicely")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
tap.test("save fixtures", function (t) {
|
||||
var fname = path.resolve(__dirname, "bash-results.json")
|
||||
var data = JSON.stringify(bashOutput, null, 2) + "\n"
|
||||
fs.writeFile(fname, data, function (er) {
|
||||
t.ifError(er)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
function cleanResults (m) {
|
||||
// normalize discrepancies in ordering, duplication,
|
||||
// and ending slashes.
|
||||
return m.map(function (m) {
|
||||
return m.replace(/\/+/g, "/").replace(/\/$/, "")
|
||||
}).sort(alphasort).reduce(function (set, f) {
|
||||
if (f !== set[set.length - 1]) set.push(f)
|
||||
return set
|
||||
}, []).sort(alphasort).map(function (f) {
|
||||
// de-windows
|
||||
return (process.platform !== 'win32') ? f
|
||||
: f.replace(/^[a-zA-Z]:\\\\/, '/').replace(/\\/g, '/')
|
||||
})
|
||||
}
|
||||
|
||||
function flatten (chunks) {
|
||||
var s = 0
|
||||
chunks.forEach(function (c) { s += c.length })
|
||||
var out = new Buffer(s)
|
||||
s = 0
|
||||
chunks.forEach(function (c) {
|
||||
c.copy(out, s)
|
||||
s += c.length
|
||||
})
|
||||
|
||||
return out.toString().trim()
|
||||
}
|
||||
|
||||
function alphasort (a, b) {
|
||||
a = a.toLowerCase()
|
||||
b = b.toLowerCase()
|
||||
return a > b ? 1 : a < b ? -1 : 0
|
||||
}
|
||||
Generated
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// basic test
|
||||
// show that it does the same thing by default as the shell.
|
||||
var tap = require("tap")
|
||||
, child_process = require("child_process")
|
||||
, bashResults = require("./bash-results.json")
|
||||
, globs = Object.keys(bashResults)
|
||||
, glob = require("../")
|
||||
, path = require("path")
|
||||
|
||||
// run from the root of the project
|
||||
// this is usually where you're at anyway, but be sure.
|
||||
process.chdir(path.resolve(__dirname, ".."))
|
||||
|
||||
function alphasort (a, b) {
|
||||
a = a.toLowerCase()
|
||||
b = b.toLowerCase()
|
||||
return a > b ? 1 : a < b ? -1 : 0
|
||||
}
|
||||
|
||||
globs.forEach(function (pattern) {
|
||||
var expect = bashResults[pattern]
|
||||
// anything regarding the symlink thing will fail on windows, so just skip it
|
||||
if (process.platform === "win32" &&
|
||||
expect.some(function (m) {
|
||||
return /\/symlink\//.test(m)
|
||||
}))
|
||||
return
|
||||
|
||||
tap.test(pattern, function (t) {
|
||||
glob(pattern, function (er, matches) {
|
||||
if (er)
|
||||
throw er
|
||||
|
||||
// sort and unmark, just to match the shell results
|
||||
matches = cleanResults(matches)
|
||||
|
||||
t.deepEqual(matches, expect, pattern)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tap.test(pattern + " sync", function (t) {
|
||||
var matches = cleanResults(glob.sync(pattern))
|
||||
|
||||
t.deepEqual(matches, expect, "should match shell")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
function cleanResults (m) {
|
||||
// normalize discrepancies in ordering, duplication,
|
||||
// and ending slashes.
|
||||
return m.map(function (m) {
|
||||
return m.replace(/\/+/g, "/").replace(/\/$/, "")
|
||||
}).sort(alphasort).reduce(function (set, f) {
|
||||
if (f !== set[set.length - 1]) set.push(f)
|
||||
return set
|
||||
}, []).sort(alphasort).map(function (f) {
|
||||
// de-windows
|
||||
return (process.platform !== 'win32') ? f
|
||||
: f.replace(/^[a-zA-Z]:[\/\\]+/, '/').replace(/[\\\/]+/g, '/')
|
||||
})
|
||||
}
|
||||
Generated
Vendored
+350
@@ -0,0 +1,350 @@
|
||||
{
|
||||
"test/a/*/+(c|g)/./d": [
|
||||
"test/a/b/c/./d"
|
||||
],
|
||||
"test/a/**/[cg]/../[cg]": [
|
||||
"test/a/abcdef/g/../g",
|
||||
"test/a/abcfed/g/../g",
|
||||
"test/a/b/c/../c",
|
||||
"test/a/c/../c",
|
||||
"test/a/c/d/c/../c",
|
||||
"test/a/symlink/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a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/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c"
|
||||
],
|
||||
"test/a/{b,c,d,e,f}/**/g": [],
|
||||
"test/a/b/**": [
|
||||
"test/a/b",
|
||||
"test/a/b/c",
|
||||
"test/a/b/c/d"
|
||||
],
|
||||
"test/**/g": [
|
||||
"test/a/abcdef/g",
|
||||
"test/a/abcfed/g"
|
||||
],
|
||||
"test/a/abc{fed,def}/g/h": [
|
||||
"test/a/abcdef/g/h",
|
||||
"test/a/abcfed/g/h"
|
||||
],
|
||||
"test/a/abc{fed/g,def}/**/": [
|
||||
"test/a/abcdef",
|
||||
"test/a/abcdef/g",
|
||||
"test/a/abcfed/g"
|
||||
],
|
||||
"test/a/abc{fed/g,def}/**///**/": [
|
||||
"test/a/abcdef",
|
||||
"test/a/abcdef/g",
|
||||
"test/a/abcfed/g"
|
||||
],
|
||||
"test/**/a/**/": [
|
||||
"test/a",
|
||||
"test/a/abcdef",
|
||||
"test/a/abcdef/g",
|
||||
"test/a/abcfed",
|
||||
"test/a/abcfed/g",
|
||||
"test/a/b",
|
||||
"test/a/b/c",
|
||||
"test/a/bc",
|
||||
"test/a/bc/e",
|
||||
"test/a/c",
|
||||
"test/a/c/d",
|
||||
"test/a/c/d/c",
|
||||
"test/a/cb",
|
||||
"test/a/cb/e",
|
||||
"test/a/symlink",
|
||||
"test/a/symlink/a",
|
||||
"test/a/symlink/a/b",
|
||||
"test/a/symlink/a/b/c",
|
||||
"test/a/symlink/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
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b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b"
|
||||
],
|
||||
"test/+(a|b|c)/a{/,bc*}/**": [
|
||||
"test/a/abcdef",
|
||||
"test/a/abcdef/g",
|
||||
"test/a/abcdef/g/h",
|
||||
"test/a/abcfed",
|
||||
"test/a/abcfed/g",
|
||||
"test/a/abcfed/g/h"
|
||||
],
|
||||
"test/*/*/*/f": [
|
||||
"test/a/bc/e/f",
|
||||
"test/a/cb/e/f"
|
||||
],
|
||||
"test/**/f": [
|
||||
"test/a/bc/e/f",
|
||||
"test/a/cb/e/f"
|
||||
],
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**": [
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b",
|
||||
"test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c",
|
||||
"test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/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c"
|
||||
],
|
||||
"{./*/*,/tmp/glob-test/*}": [
|
||||
"./examples/g.js",
|
||||
"./examples/usr-local.js",
|
||||
"./node_modules/inherits",
|
||||
"./node_modules/minimatch",
|
||||
"./node_modules/mkdirp",
|
||||
"./node_modules/rimraf",
|
||||
"./node_modules/tap",
|
||||
"./test/00-setup.js",
|
||||
"./test/a",
|
||||
"./test/bash-comparison.js",
|
||||
"./test/bash-results.json",
|
||||
"./test/cwd-test.js",
|
||||
"./test/globstar-match.js",
|
||||
"./test/mark.js",
|
||||
"./test/new-glob-optional-options.js",
|
||||
"./test/nocase-nomagic.js",
|
||||
"./test/pause-resume.js",
|
||||
"./test/root-nomount.js",
|
||||
"./test/root.js",
|
||||
"./test/stat.js",
|
||||
"./test/zz-cleanup.js",
|
||||
"/tmp/glob-test/asdf",
|
||||
"/tmp/glob-test/bar",
|
||||
"/tmp/glob-test/baz",
|
||||
"/tmp/glob-test/foo",
|
||||
"/tmp/glob-test/quux",
|
||||
"/tmp/glob-test/qwer",
|
||||
"/tmp/glob-test/rewq"
|
||||
],
|
||||
"{/tmp/glob-test/*,*}": [
|
||||
"/tmp/glob-test/asdf",
|
||||
"/tmp/glob-test/bar",
|
||||
"/tmp/glob-test/baz",
|
||||
"/tmp/glob-test/foo",
|
||||
"/tmp/glob-test/quux",
|
||||
"/tmp/glob-test/qwer",
|
||||
"/tmp/glob-test/rewq",
|
||||
"examples",
|
||||
"glob.js",
|
||||
"LICENSE",
|
||||
"node_modules",
|
||||
"package.json",
|
||||
"README.md",
|
||||
"test"
|
||||
],
|
||||
"test/a/!(symlink)/**": [
|
||||
"test/a/abcdef",
|
||||
"test/a/abcdef/g",
|
||||
"test/a/abcdef/g/h",
|
||||
"test/a/abcfed",
|
||||
"test/a/abcfed/g",
|
||||
"test/a/abcfed/g/h",
|
||||
"test/a/b",
|
||||
"test/a/b/c",
|
||||
"test/a/b/c/d",
|
||||
"test/a/bc",
|
||||
"test/a/bc/e",
|
||||
"test/a/bc/e/f",
|
||||
"test/a/c",
|
||||
"test/a/c/d",
|
||||
"test/a/c/d/c",
|
||||
"test/a/c/d/c/b",
|
||||
"test/a/cb",
|
||||
"test/a/cb/e",
|
||||
"test/a/cb/e/f"
|
||||
]
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
var tap = require("tap")
|
||||
|
||||
var origCwd = process.cwd()
|
||||
process.chdir(__dirname)
|
||||
|
||||
tap.test("changing cwd and searching for **/d", function (t) {
|
||||
var glob = require('../')
|
||||
var path = require('path')
|
||||
t.test('.', function (t) {
|
||||
glob('**/d', function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('a', function (t) {
|
||||
glob('**/d', {cwd:path.resolve('a')}, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ 'b/c/d', 'c/d' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('a/b', function (t) {
|
||||
glob('**/d', {cwd:path.resolve('a/b')}, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ 'c/d' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('a/b/', function (t) {
|
||||
glob('**/d', {cwd:path.resolve('a/b/')}, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ 'c/d' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('.', function (t) {
|
||||
glob('**/d', {cwd: process.cwd()}, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ 'a/b/c/d', 'a/c/d' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('cd -', function (t) {
|
||||
process.chdir(origCwd)
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
var Glob = require("../glob.js").Glob
|
||||
var test = require('tap').test
|
||||
|
||||
test('globstar should not have dupe matches', function(t) {
|
||||
var pattern = 'a/**/[gh]'
|
||||
var g = new Glob(pattern, { cwd: __dirname })
|
||||
var matches = []
|
||||
g.on('match', function(m) {
|
||||
console.error('match %j', m)
|
||||
matches.push(m)
|
||||
})
|
||||
g.on('end', function(set) {
|
||||
console.error('set', set)
|
||||
matches = matches.sort()
|
||||
set = set.sort()
|
||||
t.same(matches, set, 'should have same set of matches')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
var test = require("tap").test
|
||||
var glob = require('../')
|
||||
process.chdir(__dirname)
|
||||
|
||||
test("mark, no / on pattern", function (t) {
|
||||
glob("a/*", {mark: true}, function (er, results) {
|
||||
if (er)
|
||||
throw er
|
||||
var expect = [ 'a/abcdef/',
|
||||
'a/abcfed/',
|
||||
'a/b/',
|
||||
'a/bc/',
|
||||
'a/c/',
|
||||
'a/cb/' ]
|
||||
|
||||
if (process.platform !== "win32")
|
||||
expect.push('a/symlink/')
|
||||
|
||||
t.same(results, expect)
|
||||
t.end()
|
||||
}).on('match', function(m) {
|
||||
t.similar(m, /\/$/)
|
||||
})
|
||||
})
|
||||
|
||||
test("mark=false, no / on pattern", function (t) {
|
||||
glob("a/*", function (er, results) {
|
||||
if (er)
|
||||
throw er
|
||||
var expect = [ 'a/abcdef',
|
||||
'a/abcfed',
|
||||
'a/b',
|
||||
'a/bc',
|
||||
'a/c',
|
||||
'a/cb' ]
|
||||
|
||||
if (process.platform !== "win32")
|
||||
expect.push('a/symlink')
|
||||
t.same(results, expect)
|
||||
t.end()
|
||||
}).on('match', function(m) {
|
||||
t.similar(m, /[^\/]$/)
|
||||
})
|
||||
})
|
||||
|
||||
test("mark=true, / on pattern", function (t) {
|
||||
glob("a/*/", {mark: true}, function (er, results) {
|
||||
if (er)
|
||||
throw er
|
||||
var expect = [ 'a/abcdef/',
|
||||
'a/abcfed/',
|
||||
'a/b/',
|
||||
'a/bc/',
|
||||
'a/c/',
|
||||
'a/cb/' ]
|
||||
if (process.platform !== "win32")
|
||||
expect.push('a/symlink/')
|
||||
t.same(results, expect)
|
||||
t.end()
|
||||
}).on('match', function(m) {
|
||||
t.similar(m, /\/$/)
|
||||
})
|
||||
})
|
||||
|
||||
test("mark=false, / on pattern", function (t) {
|
||||
glob("a/*/", function (er, results) {
|
||||
if (er)
|
||||
throw er
|
||||
var expect = [ 'a/abcdef/',
|
||||
'a/abcfed/',
|
||||
'a/b/',
|
||||
'a/bc/',
|
||||
'a/c/',
|
||||
'a/cb/' ]
|
||||
if (process.platform !== "win32")
|
||||
expect.push('a/symlink/')
|
||||
t.same(results, expect)
|
||||
t.end()
|
||||
}).on('match', function(m) {
|
||||
t.similar(m, /\/$/)
|
||||
})
|
||||
})
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
var Glob = require('../glob.js').Glob;
|
||||
var test = require('tap').test;
|
||||
|
||||
test('new glob, with cb, and no options', function (t) {
|
||||
new Glob(__filename, function(er, results) {
|
||||
if (er) throw er;
|
||||
t.same(results, [__filename]);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+113
@@ -0,0 +1,113 @@
|
||||
var fs = require('fs');
|
||||
var test = require('tap').test;
|
||||
var glob = require('../');
|
||||
|
||||
test('mock fs', function(t) {
|
||||
var stat = fs.stat
|
||||
var statSync = fs.statSync
|
||||
var readdir = fs.readdir
|
||||
var readdirSync = fs.readdirSync
|
||||
|
||||
function fakeStat(path) {
|
||||
var ret
|
||||
switch (path.toLowerCase()) {
|
||||
case '/tmp': case '/tmp/':
|
||||
ret = { isDirectory: function() { return true } }
|
||||
break
|
||||
case '/tmp/a':
|
||||
ret = { isDirectory: function() { return false } }
|
||||
break
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
fs.stat = function(path, cb) {
|
||||
var f = fakeStat(path);
|
||||
if (f) {
|
||||
process.nextTick(function() {
|
||||
cb(null, f)
|
||||
})
|
||||
} else {
|
||||
stat.call(fs, path, cb)
|
||||
}
|
||||
}
|
||||
|
||||
fs.statSync = function(path) {
|
||||
return fakeStat(path) || statSync.call(fs, path)
|
||||
}
|
||||
|
||||
function fakeReaddir(path) {
|
||||
var ret
|
||||
switch (path.toLowerCase()) {
|
||||
case '/tmp': case '/tmp/':
|
||||
ret = [ 'a', 'A' ]
|
||||
break
|
||||
case '/':
|
||||
ret = ['tmp', 'tMp', 'tMP', 'TMP']
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
fs.readdir = function(path, cb) {
|
||||
var f = fakeReaddir(path)
|
||||
if (f)
|
||||
process.nextTick(function() {
|
||||
cb(null, f)
|
||||
})
|
||||
else
|
||||
readdir.call(fs, path, cb)
|
||||
}
|
||||
|
||||
fs.readdirSync = function(path) {
|
||||
return fakeReaddir(path) || readdirSync.call(fs, path)
|
||||
}
|
||||
|
||||
t.pass('mocked')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('nocase, nomagic', function(t) {
|
||||
var n = 2
|
||||
var want = [ '/TMP/A',
|
||||
'/TMP/a',
|
||||
'/tMP/A',
|
||||
'/tMP/a',
|
||||
'/tMp/A',
|
||||
'/tMp/a',
|
||||
'/tmp/A',
|
||||
'/tmp/a' ]
|
||||
glob('/tmp/a', { nocase: true }, function(er, res) {
|
||||
if (er)
|
||||
throw er
|
||||
t.same(res.sort(), want)
|
||||
if (--n === 0) t.end()
|
||||
})
|
||||
glob('/tmp/A', { nocase: true }, function(er, res) {
|
||||
if (er)
|
||||
throw er
|
||||
t.same(res.sort(), want)
|
||||
if (--n === 0) t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('nocase, with some magic', function(t) {
|
||||
t.plan(2)
|
||||
var want = [ '/TMP/A',
|
||||
'/TMP/a',
|
||||
'/tMP/A',
|
||||
'/tMP/a',
|
||||
'/tMp/A',
|
||||
'/tMp/a',
|
||||
'/tmp/A',
|
||||
'/tmp/a' ]
|
||||
glob('/tmp/*', { nocase: true }, function(er, res) {
|
||||
if (er)
|
||||
throw er
|
||||
t.same(res.sort(), want)
|
||||
})
|
||||
glob('/tmp/*', { nocase: true }, function(er, res) {
|
||||
if (er)
|
||||
throw er
|
||||
t.same(res.sort(), want)
|
||||
})
|
||||
})
|
||||
Generated
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
// show that no match events happen while paused.
|
||||
var tap = require("tap")
|
||||
, child_process = require("child_process")
|
||||
// just some gnarly pattern with lots of matches
|
||||
, pattern = "test/a/!(symlink)/**"
|
||||
, bashResults = require("./bash-results.json")
|
||||
, patterns = Object.keys(bashResults)
|
||||
, glob = require("../")
|
||||
, Glob = glob.Glob
|
||||
, path = require("path")
|
||||
|
||||
// run from the root of the project
|
||||
// this is usually where you're at anyway, but be sure.
|
||||
process.chdir(path.resolve(__dirname, ".."))
|
||||
|
||||
function alphasort (a, b) {
|
||||
a = a.toLowerCase()
|
||||
b = b.toLowerCase()
|
||||
return a > b ? 1 : a < b ? -1 : 0
|
||||
}
|
||||
|
||||
function cleanResults (m) {
|
||||
// normalize discrepancies in ordering, duplication,
|
||||
// and ending slashes.
|
||||
return m.map(function (m) {
|
||||
return m.replace(/\/+/g, "/").replace(/\/$/, "")
|
||||
}).sort(alphasort).reduce(function (set, f) {
|
||||
if (f !== set[set.length - 1]) set.push(f)
|
||||
return set
|
||||
}, []).sort(alphasort).map(function (f) {
|
||||
// de-windows
|
||||
return (process.platform !== 'win32') ? f
|
||||
: f.replace(/^[a-zA-Z]:\\\\/, '/').replace(/\\/g, '/')
|
||||
})
|
||||
}
|
||||
|
||||
var globResults = []
|
||||
tap.test("use a Glob object, and pause/resume it", function (t) {
|
||||
var g = new Glob(pattern)
|
||||
, paused = false
|
||||
, res = []
|
||||
, expect = bashResults[pattern]
|
||||
|
||||
g.on("pause", function () {
|
||||
console.error("pause")
|
||||
})
|
||||
|
||||
g.on("resume", function () {
|
||||
console.error("resume")
|
||||
})
|
||||
|
||||
g.on("match", function (m) {
|
||||
t.notOk(g.paused, "must not be paused")
|
||||
globResults.push(m)
|
||||
g.pause()
|
||||
t.ok(g.paused, "must be paused")
|
||||
setTimeout(g.resume.bind(g), 10)
|
||||
})
|
||||
|
||||
g.on("end", function (matches) {
|
||||
t.pass("reached glob end")
|
||||
globResults = cleanResults(globResults)
|
||||
matches = cleanResults(matches)
|
||||
t.deepEqual(matches, globResults,
|
||||
"end event matches should be the same as match events")
|
||||
|
||||
t.deepEqual(matches, expect,
|
||||
"glob matches should be the same as bash results")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
Generated
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
var tap = require("tap")
|
||||
|
||||
var origCwd = process.cwd()
|
||||
process.chdir(__dirname)
|
||||
|
||||
tap.test("changing root and searching for /b*/**", function (t) {
|
||||
var glob = require('../')
|
||||
var path = require('path')
|
||||
t.test('.', function (t) {
|
||||
glob('/b*/**', { globDebug: true, root: '.', nomount: true }, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('a', function (t) {
|
||||
glob('/b*/**', { globDebug: true, root: path.resolve('a'), nomount: true }, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('root=a, cwd=a/b', function (t) {
|
||||
glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b'), nomount: true }, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('cd -', function (t) {
|
||||
process.chdir(origCwd)
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
var t = require("tap")
|
||||
|
||||
var origCwd = process.cwd()
|
||||
process.chdir(__dirname)
|
||||
|
||||
var glob = require('../')
|
||||
var path = require('path')
|
||||
|
||||
t.test('.', function (t) {
|
||||
glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [])
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
t.test('a', function (t) {
|
||||
console.error("root=" + path.resolve('a'))
|
||||
glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) {
|
||||
t.ifError(er)
|
||||
var wanted = [
|
||||
'/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f'
|
||||
].map(function (m) {
|
||||
return path.join(path.resolve('a'), m).replace(/\\/g, '/')
|
||||
})
|
||||
|
||||
t.like(matches, wanted)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('root=a, cwd=a/b', function (t) {
|
||||
glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) {
|
||||
t.ifError(er)
|
||||
t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
|
||||
return path.join(path.resolve('a'), m).replace(/\\/g, '/')
|
||||
}))
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('cd -', function (t) {
|
||||
process.chdir(origCwd)
|
||||
t.end()
|
||||
})
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
var glob = require('../')
|
||||
var test = require('tap').test
|
||||
var path = require('path')
|
||||
|
||||
test('stat all the things', function(t) {
|
||||
var g = new glob.Glob('a/*abc*/**', { stat: true, cwd: __dirname })
|
||||
var matches = []
|
||||
g.on('match', function(m) {
|
||||
matches.push(m)
|
||||
})
|
||||
var stats = []
|
||||
g.on('stat', function(m) {
|
||||
stats.push(m)
|
||||
})
|
||||
g.on('end', function(eof) {
|
||||
stats = stats.sort()
|
||||
matches = matches.sort()
|
||||
eof = eof.sort()
|
||||
t.same(stats, matches)
|
||||
t.same(eof, matches)
|
||||
var cache = Object.keys(this.statCache)
|
||||
t.same(cache.map(function (f) {
|
||||
return path.relative(__dirname, f)
|
||||
}).sort(), matches)
|
||||
|
||||
cache.forEach(function(c) {
|
||||
t.equal(typeof this.statCache[c], 'object')
|
||||
}, this)
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// remove the fixtures
|
||||
var tap = require("tap")
|
||||
, rimraf = require("rimraf")
|
||||
, path = require("path")
|
||||
|
||||
tap.test("cleanup fixtures", function (t) {
|
||||
rimraf(path.resolve(__dirname, "a"), function (er) {
|
||||
t.ifError(er, "removed")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
+1
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
# minimatch
|
||||
|
||||
A minimal matching utility.
|
||||
|
||||
[](http://travis-ci.org/isaacs/minimatch)
|
||||
|
||||
|
||||
This is the matching library used internally by npm.
|
||||
|
||||
Eventually, it will replace the C binding in node-glob.
|
||||
|
||||
It works by converting glob expressions into JavaScript `RegExp`
|
||||
objects.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var minimatch = require("minimatch")
|
||||
|
||||
minimatch("bar.foo", "*.foo") // true!
|
||||
minimatch("bar.foo", "*.bar") // false!
|
||||
minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy!
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
Supports these glob features:
|
||||
|
||||
* Brace Expansion
|
||||
* Extended glob matching
|
||||
* "Globstar" `**` matching
|
||||
|
||||
See:
|
||||
|
||||
* `man sh`
|
||||
* `man bash`
|
||||
* `man 3 fnmatch`
|
||||
* `man 5 gitignore`
|
||||
|
||||
## Minimatch Class
|
||||
|
||||
Create a minimatch object by instanting the `minimatch.Minimatch` class.
|
||||
|
||||
```javascript
|
||||
var Minimatch = require("minimatch").Minimatch
|
||||
var mm = new Minimatch(pattern, options)
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
* `pattern` The original pattern the minimatch object represents.
|
||||
* `options` The options supplied to the constructor.
|
||||
* `set` A 2-dimensional array of regexp or string expressions.
|
||||
Each row in the
|
||||
array corresponds to a brace-expanded pattern. Each item in the row
|
||||
corresponds to a single path-part. For example, the pattern
|
||||
`{a,b/c}/d` would expand to a set of patterns like:
|
||||
|
||||
[ [ a, d ]
|
||||
, [ b, c, d ] ]
|
||||
|
||||
If a portion of the pattern doesn't have any "magic" in it
|
||||
(that is, it's something like `"foo"` rather than `fo*o?`), then it
|
||||
will be left as a string rather than converted to a regular
|
||||
expression.
|
||||
|
||||
* `regexp` Created by the `makeRe` method. A single regular expression
|
||||
expressing the entire pattern. This is useful in cases where you wish
|
||||
to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled.
|
||||
* `negate` True if the pattern is negated.
|
||||
* `comment` True if the pattern is a comment.
|
||||
* `empty` True if the pattern is `""`.
|
||||
|
||||
### Methods
|
||||
|
||||
* `makeRe` Generate the `regexp` member if necessary, and return it.
|
||||
Will return `false` if the pattern is invalid.
|
||||
* `match(fname)` Return true if the filename matches the pattern, or
|
||||
false otherwise.
|
||||
* `matchOne(fileArray, patternArray, partial)` Take a `/`-split
|
||||
filename, and match it against a single row in the `regExpSet`. This
|
||||
method is mainly for internal use, but is exposed so that it can be
|
||||
used by a glob-walker that needs to avoid excessive filesystem calls.
|
||||
|
||||
All other methods are internal, and will be called as necessary.
|
||||
|
||||
## Functions
|
||||
|
||||
The top-level exported function has a `cache` property, which is an LRU
|
||||
cache set to store 100 items. So, calling these methods repeatedly
|
||||
with the same pattern and options will use the same Minimatch object,
|
||||
saving the cost of parsing it multiple times.
|
||||
|
||||
### minimatch(path, pattern, options)
|
||||
|
||||
Main export. Tests a path against the pattern using the options.
|
||||
|
||||
```javascript
|
||||
var isJS = minimatch(file, "*.js", { matchBase: true })
|
||||
```
|
||||
|
||||
### minimatch.filter(pattern, options)
|
||||
|
||||
Returns a function that tests its
|
||||
supplied argument, suitable for use with `Array.filter`. Example:
|
||||
|
||||
```javascript
|
||||
var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true}))
|
||||
```
|
||||
|
||||
### minimatch.match(list, pattern, options)
|
||||
|
||||
Match against the list of
|
||||
files, in the style of fnmatch or glob. If nothing is matched, and
|
||||
options.nonull is set, then return a list containing the pattern itself.
|
||||
|
||||
```javascript
|
||||
var javascripts = minimatch.match(fileList, "*.js", {matchBase: true}))
|
||||
```
|
||||
|
||||
### minimatch.makeRe(pattern, options)
|
||||
|
||||
Make a regular expression object from the pattern.
|
||||
|
||||
## Options
|
||||
|
||||
All options are `false` by default.
|
||||
|
||||
### debug
|
||||
|
||||
Dump a ton of stuff to stderr.
|
||||
|
||||
### nobrace
|
||||
|
||||
Do not expand `{a,b}` and `{1..3}` brace sets.
|
||||
|
||||
### noglobstar
|
||||
|
||||
Disable `**` matching against multiple folder names.
|
||||
|
||||
### dot
|
||||
|
||||
Allow patterns to match filenames starting with a period, even if
|
||||
the pattern does not explicitly have a period in that spot.
|
||||
|
||||
Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot`
|
||||
is set.
|
||||
|
||||
### noext
|
||||
|
||||
Disable "extglob" style patterns like `+(a|b)`.
|
||||
|
||||
### nocase
|
||||
|
||||
Perform a case-insensitive match.
|
||||
|
||||
### nonull
|
||||
|
||||
When a match is not found by `minimatch.match`, return a list containing
|
||||
the pattern itself. When set, an empty list is returned if there are
|
||||
no matches.
|
||||
|
||||
### matchBase
|
||||
|
||||
If set, then patterns without slashes will be matched
|
||||
against the basename of the path if it contains slashes. For example,
|
||||
`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.
|
||||
|
||||
### nocomment
|
||||
|
||||
Suppress the behavior of treating `#` at the start of a pattern as a
|
||||
comment.
|
||||
|
||||
### nonegate
|
||||
|
||||
Suppress the behavior of treating a leading `!` character as negation.
|
||||
|
||||
### flipNegate
|
||||
|
||||
Returns from negate expressions the same as if they were not negated.
|
||||
(Ie, true on a hit, false on a miss.)
|
||||
|
||||
|
||||
## Comparisons to other fnmatch/glob implementations
|
||||
|
||||
While strict compliance with the existing standards is a worthwhile
|
||||
goal, some discrepancies exist between minimatch and other
|
||||
implementations, and are intentional.
|
||||
|
||||
If the pattern starts with a `!` character, then it is negated. Set the
|
||||
`nonegate` flag to suppress this behavior, and treat leading `!`
|
||||
characters normally. This is perhaps relevant if you wish to start the
|
||||
pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
|
||||
characters at the start of a pattern will negate the pattern multiple
|
||||
times.
|
||||
|
||||
If a pattern starts with `#`, then it is treated as a comment, and
|
||||
will not match anything. Use `\#` to match a literal `#` at the
|
||||
start of a line, or set the `nocomment` flag to suppress this behavior.
|
||||
|
||||
The double-star character `**` is supported by default, unless the
|
||||
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
||||
and bash 4.1, where `**` only has special significance if it is the only
|
||||
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
||||
`a/**b` will not.
|
||||
|
||||
If an escaped pattern has no matches, and the `nonull` flag is set,
|
||||
then minimatch.match returns the pattern as-provided, rather than
|
||||
interpreting the character escapes. For example,
|
||||
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
||||
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
||||
that it does not resolve escaped pattern characters.
|
||||
|
||||
If brace expansion is not disabled, then it is performed before any
|
||||
other interpretation of the glob pattern. Thus, a pattern like
|
||||
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
||||
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
||||
checked for validity. Since those two are valid, matching proceeds.
|
||||
Generated
Vendored
+1055
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"minimatch@0.2.14",
|
||||
"/mnt/data/Sites/r2c.net/user/themes/r2c"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "minimatch@0.2.14",
|
||||
"_id": "minimatch@0.2.14",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=",
|
||||
"_location": "/vow-fs/minimatch",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "minimatch@0.2.14",
|
||||
"name": "minimatch",
|
||||
"escapedName": "minimatch",
|
||||
"rawSpec": "0.2.14",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.2.14"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vow-fs/glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz",
|
||||
"_spec": "0.2.14",
|
||||
"_where": "/mnt/data/Sites/r2c.net/user/themes/r2c",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/minimatch/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"lru-cache": "2",
|
||||
"sigmund": "~1.0.0"
|
||||
},
|
||||
"description": "a glob matcher in javascript",
|
||||
"devDependencies": {
|
||||
"tap": ""
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/isaacs/minimatch#readme",
|
||||
"license": {
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/isaacs/minimatch/raw/master/LICENSE"
|
||||
},
|
||||
"main": "minimatch.js",
|
||||
"name": "minimatch",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/minimatch.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "0.2.14"
|
||||
}
|
||||
Generated
Vendored
+399
@@ -0,0 +1,399 @@
|
||||
// http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test
|
||||
//
|
||||
// TODO: Some of these tests do very bad things with backslashes, and will
|
||||
// most likely fail badly on windows. They should probably be skipped.
|
||||
|
||||
var tap = require("tap")
|
||||
, globalBefore = Object.keys(global)
|
||||
, mm = require("../")
|
||||
, files = [ "a", "b", "c", "d", "abc"
|
||||
, "abd", "abe", "bb", "bcd"
|
||||
, "ca", "cb", "dd", "de"
|
||||
, "bdir/", "bdir/cfile"]
|
||||
, next = files.concat([ "a-b", "aXb"
|
||||
, ".x", ".y" ])
|
||||
|
||||
|
||||
var patterns =
|
||||
[ "http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test"
|
||||
, ["a*", ["a", "abc", "abd", "abe"]]
|
||||
, ["X*", ["X*"], {nonull: true}]
|
||||
|
||||
// allow null glob expansion
|
||||
, ["X*", []]
|
||||
|
||||
// isaacs: Slightly different than bash/sh/ksh
|
||||
// \\* is not un-escaped to literal "*" in a failed match,
|
||||
// but it does make it get treated as a literal star
|
||||
, ["\\*", ["\\*"], {nonull: true}]
|
||||
, ["\\**", ["\\**"], {nonull: true}]
|
||||
, ["\\*\\*", ["\\*\\*"], {nonull: true}]
|
||||
|
||||
, ["b*/", ["bdir/"]]
|
||||
, ["c*", ["c", "ca", "cb"]]
|
||||
, ["**", files]
|
||||
|
||||
, ["\\.\\./*/", ["\\.\\./*/"], {nonull: true}]
|
||||
, ["s/\\..*//", ["s/\\..*//"], {nonull: true}]
|
||||
|
||||
, "legendary larry crashes bashes"
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/"
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/"], {nonull: true}]
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/"
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/"], {nonull: true}]
|
||||
|
||||
, "character classes"
|
||||
, ["[a-c]b*", ["abc", "abd", "abe", "bb", "cb"]]
|
||||
, ["[a-y]*[^c]", ["abd", "abe", "bb", "bcd",
|
||||
"bdir/", "ca", "cb", "dd", "de"]]
|
||||
, ["a*[^c]", ["abd", "abe"]]
|
||||
, function () { files.push("a-b", "aXb") }
|
||||
, ["a[X-]b", ["a-b", "aXb"]]
|
||||
, function () { files.push(".x", ".y") }
|
||||
, ["[^a-c]*", ["d", "dd", "de"]]
|
||||
, function () { files.push("a*b/", "a*b/ooo") }
|
||||
, ["a\\*b/*", ["a*b/ooo"]]
|
||||
, ["a\\*?/*", ["a*b/ooo"]]
|
||||
, ["*\\\\!*", [], {null: true}, ["echo !7"]]
|
||||
, ["*\\!*", ["echo !7"], null, ["echo !7"]]
|
||||
, ["*.\\*", ["r.*"], null, ["r.*"]]
|
||||
, ["a[b]c", ["abc"]]
|
||||
, ["a[\\b]c", ["abc"]]
|
||||
, ["a?c", ["abc"]]
|
||||
, ["a\\*c", [], {null: true}, ["abc"]]
|
||||
, ["", [""], { null: true }, [""]]
|
||||
|
||||
, "http://www.opensource.apple.com/source/bash/bash-23/" +
|
||||
"bash/tests/glob-test"
|
||||
, function () { files.push("man/", "man/man1/", "man/man1/bash.1") }
|
||||
, ["*/man*/bash.*", ["man/man1/bash.1"]]
|
||||
, ["man/man1/bash.1", ["man/man1/bash.1"]]
|
||||
, ["a***c", ["abc"], null, ["abc"]]
|
||||
, ["a*****?c", ["abc"], null, ["abc"]]
|
||||
, ["?*****??", ["abc"], null, ["abc"]]
|
||||
, ["*****??", ["abc"], null, ["abc"]]
|
||||
, ["?*****?c", ["abc"], null, ["abc"]]
|
||||
, ["?***?****c", ["abc"], null, ["abc"]]
|
||||
, ["?***?****?", ["abc"], null, ["abc"]]
|
||||
, ["?***?****", ["abc"], null, ["abc"]]
|
||||
, ["*******c", ["abc"], null, ["abc"]]
|
||||
, ["*******?", ["abc"], null, ["abc"]]
|
||||
, ["a*cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??k***", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??***k", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??***k**", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a****c**?**??*****", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["[-abc]", ["-"], null, ["-"]]
|
||||
, ["[abc-]", ["-"], null, ["-"]]
|
||||
, ["\\", ["\\"], null, ["\\"]]
|
||||
, ["[\\\\]", ["\\"], null, ["\\"]]
|
||||
, ["[[]", ["["], null, ["["]]
|
||||
, ["[", ["["], null, ["["]]
|
||||
, ["[*", ["[abc"], null, ["[abc"]]
|
||||
, "a right bracket shall lose its special meaning and\n" +
|
||||
"represent itself in a bracket expression if it occurs\n" +
|
||||
"first in the list. -- POSIX.2 2.8.3.2"
|
||||
, ["[]]", ["]"], null, ["]"]]
|
||||
, ["[]-]", ["]"], null, ["]"]]
|
||||
, ["[a-\z]", ["p"], null, ["p"]]
|
||||
, ["??**********?****?", [], { null: true }, ["abc"]]
|
||||
, ["??**********?****c", [], { null: true }, ["abc"]]
|
||||
, ["?************c****?****", [], { null: true }, ["abc"]]
|
||||
, ["*c*?**", [], { null: true }, ["abc"]]
|
||||
, ["a*****c*?**", [], { null: true }, ["abc"]]
|
||||
, ["a********???*******", [], { null: true }, ["abc"]]
|
||||
, ["[]", [], { null: true }, ["a"]]
|
||||
, ["[abc", [], { null: true }, ["["]]
|
||||
|
||||
, "nocase tests"
|
||||
, ["XYZ", ["xYz"], { nocase: true, null: true }
|
||||
, ["xYz", "ABC", "IjK"]]
|
||||
, ["ab*", ["ABC"], { nocase: true, null: true }
|
||||
, ["xYz", "ABC", "IjK"]]
|
||||
, ["[ia]?[ck]", ["ABC", "IjK"], { nocase: true, null: true }
|
||||
, ["xYz", "ABC", "IjK"]]
|
||||
|
||||
// [ pattern, [matches], MM opts, files, TAP opts]
|
||||
, "onestar/twostar"
|
||||
, ["{/*,*}", [], {null: true}, ["/asdf/asdf/asdf"]]
|
||||
, ["{/?,*}", ["/a", "bb"], {null: true}
|
||||
, ["/a", "/b/b", "/a/b/c", "bb"]]
|
||||
|
||||
, "dots should not match unless requested"
|
||||
, ["**", ["a/b"], {}, ["a/b", "a/.d", ".a/.d"]]
|
||||
|
||||
// .. and . can only match patterns starting with .,
|
||||
// even when options.dot is set.
|
||||
, function () {
|
||||
files = ["a/./b", "a/../b", "a/c/b", "a/.d/b"]
|
||||
}
|
||||
, ["a/*/b", ["a/c/b", "a/.d/b"], {dot: true}]
|
||||
, ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: true}]
|
||||
, ["a/*/b", ["a/c/b"], {dot:false}]
|
||||
, ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: false}]
|
||||
|
||||
|
||||
// this also tests that changing the options needs
|
||||
// to change the cache key, even if the pattern is
|
||||
// the same!
|
||||
, ["**", ["a/b","a/.d",".a/.d"], { dot: true }
|
||||
, [ ".a/.d", "a/.d", "a/b"]]
|
||||
|
||||
, "paren sets cannot contain slashes"
|
||||
, ["*(a/b)", ["*(a/b)"], {nonull: true}, ["a/b"]]
|
||||
|
||||
// brace sets trump all else.
|
||||
//
|
||||
// invalid glob pattern. fails on bash4 and bsdglob.
|
||||
// however, in this implementation, it's easier just
|
||||
// to do the intuitive thing, and let brace-expansion
|
||||
// actually come before parsing any extglob patterns,
|
||||
// like the documentation seems to say.
|
||||
//
|
||||
// XXX: if anyone complains about this, either fix it
|
||||
// or tell them to grow up and stop complaining.
|
||||
//
|
||||
// bash/bsdglob says this:
|
||||
// , ["*(a|{b),c)}", ["*(a|{b),c)}"], {}, ["a", "ab", "ac", "ad"]]
|
||||
// but we do this instead:
|
||||
, ["*(a|{b),c)}", ["a", "ab", "ac"], {}, ["a", "ab", "ac", "ad"]]
|
||||
|
||||
// test partial parsing in the presence of comment/negation chars
|
||||
, ["[!a*", ["[!ab"], {}, ["[!ab", "[ab"]]
|
||||
, ["[#a*", ["[#ab"], {}, ["[#ab", "[ab"]]
|
||||
|
||||
// like: {a,b|c\\,d\\\|e} except it's unclosed, so it has to be escaped.
|
||||
, ["+(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g"
|
||||
, ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g"]
|
||||
, {}
|
||||
, ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g", "a", "b\\c"]]
|
||||
|
||||
|
||||
// crazy nested {,,} and *(||) tests.
|
||||
, function () {
|
||||
files = [ "a", "b", "c", "d"
|
||||
, "ab", "ac", "ad"
|
||||
, "bc", "cb"
|
||||
, "bc,d", "c,db", "c,d"
|
||||
, "d)", "(b|c", "*(b|c"
|
||||
, "b|c", "b|cc", "cb|c"
|
||||
, "x(a|b|c)", "x(a|c)"
|
||||
, "(a|b|c)", "(a|c)"]
|
||||
}
|
||||
, ["*(a|{b,c})", ["a", "b", "c", "ab", "ac"]]
|
||||
, ["{a,*(b|c,d)}", ["a","(b|c", "*(b|c", "d)"]]
|
||||
// a
|
||||
// *(b|c)
|
||||
// *(b|d)
|
||||
, ["{a,*(b|{c,d})}", ["a","b", "bc", "cb", "c", "d"]]
|
||||
, ["*(a|{b|c,c})", ["a", "b", "c", "ab", "ac", "bc", "cb"]]
|
||||
|
||||
|
||||
// test various flag settings.
|
||||
, [ "*(a|{b|c,c})", ["x(a|b|c)", "x(a|c)", "(a|b|c)", "(a|c)"]
|
||||
, { noext: true } ]
|
||||
, ["a?b", ["x/y/acb", "acb/"], {matchBase: true}
|
||||
, ["x/y/acb", "acb/", "acb/d/e", "x/y/acb/d"] ]
|
||||
, ["#*", ["#a", "#b"], {nocomment: true}, ["#a", "#b", "c#d"]]
|
||||
|
||||
|
||||
// begin channelling Boole and deMorgan...
|
||||
, "negation tests"
|
||||
, function () {
|
||||
files = ["d", "e", "!ab", "!abc", "a!b", "\\!a"]
|
||||
}
|
||||
|
||||
// anything that is NOT a* matches.
|
||||
, ["!a*", ["\\!a", "d", "e", "!ab", "!abc"]]
|
||||
|
||||
// anything that IS !a* matches.
|
||||
, ["!a*", ["!ab", "!abc"], {nonegate: true}]
|
||||
|
||||
// anything that IS a* matches
|
||||
, ["!!a*", ["a!b"]]
|
||||
|
||||
// anything that is NOT !a* matches
|
||||
, ["!\\!a*", ["a!b", "d", "e", "\\!a"]]
|
||||
|
||||
// negation nestled within a pattern
|
||||
, function () {
|
||||
files = [ "foo.js"
|
||||
, "foo.bar"
|
||||
// can't match this one without negative lookbehind.
|
||||
, "foo.js.js"
|
||||
, "blar.js"
|
||||
, "foo."
|
||||
, "boo.js.boo" ]
|
||||
}
|
||||
, ["*.!(js)", ["foo.bar", "foo.", "boo.js.boo"] ]
|
||||
|
||||
// https://github.com/isaacs/minimatch/issues/5
|
||||
, function () {
|
||||
files = [ 'a/b/.x/c'
|
||||
, 'a/b/.x/c/d'
|
||||
, 'a/b/.x/c/d/e'
|
||||
, 'a/b/.x'
|
||||
, 'a/b/.x/'
|
||||
, 'a/.x/b'
|
||||
, '.x'
|
||||
, '.x/'
|
||||
, '.x/a'
|
||||
, '.x/a/b'
|
||||
, 'a/.x/b/.x/c'
|
||||
, '.x/.x' ]
|
||||
}
|
||||
, ["**/.x/**", [ '.x/'
|
||||
, '.x/a'
|
||||
, '.x/a/b'
|
||||
, 'a/.x/b'
|
||||
, 'a/b/.x/'
|
||||
, 'a/b/.x/c'
|
||||
, 'a/b/.x/c/d'
|
||||
, 'a/b/.x/c/d/e' ] ]
|
||||
|
||||
]
|
||||
|
||||
var regexps =
|
||||
[ '/^(?:(?=.)a[^/]*?)$/',
|
||||
'/^(?:(?=.)X[^/]*?)$/',
|
||||
'/^(?:(?=.)X[^/]*?)$/',
|
||||
'/^(?:\\*)$/',
|
||||
'/^(?:(?=.)\\*[^/]*?)$/',
|
||||
'/^(?:\\*\\*)$/',
|
||||
'/^(?:(?=.)b[^/]*?\\/)$/',
|
||||
'/^(?:(?=.)c[^/]*?)$/',
|
||||
'/^(?:(?:(?!(?:\\/|^)\\.).)*?)$/',
|
||||
'/^(?:\\.\\.\\/(?!\\.)(?=.)[^/]*?\\/)$/',
|
||||
'/^(?:s\\/(?=.)\\.\\.[^/]*?\\/)$/',
|
||||
'/^(?:\\/\\^root:\\/\\{s\\/(?=.)\\^[^:][^/]*?:[^:][^/]*?:\\([^:]\\)[^/]*?\\.[^/]*?\\$\\/1\\/)$/',
|
||||
'/^(?:\\/\\^root:\\/\\{s\\/(?=.)\\^[^:][^/]*?:[^:][^/]*?:\\([^:]\\)[^/]*?\\.[^/]*?\\$\\/\u0001\\/)$/',
|
||||
'/^(?:(?!\\.)(?=.)[a-c]b[^/]*?)$/',
|
||||
'/^(?:(?!\\.)(?=.)[a-y][^/]*?[^c])$/',
|
||||
'/^(?:(?=.)a[^/]*?[^c])$/',
|
||||
'/^(?:(?=.)a[X-]b)$/',
|
||||
'/^(?:(?!\\.)(?=.)[^a-c][^/]*?)$/',
|
||||
'/^(?:a\\*b\\/(?!\\.)(?=.)[^/]*?)$/',
|
||||
'/^(?:(?=.)a\\*[^/]\\/(?!\\.)(?=.)[^/]*?)$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/]*?\\\\\\![^/]*?)$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/]*?\\![^/]*?)$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/]*?\\.\\*)$/',
|
||||
'/^(?:(?=.)a[b]c)$/',
|
||||
'/^(?:(?=.)a[b]c)$/',
|
||||
'/^(?:(?=.)a[^/]c)$/',
|
||||
'/^(?:a\\*c)$/',
|
||||
'false',
|
||||
'/^(?:(?!\\.)(?=.)[^/]*?\\/(?=.)man[^/]*?\\/(?=.)bash\\.[^/]*?)$/',
|
||||
'/^(?:man\\/man1\\/bash\\.1)$/',
|
||||
'/^(?:(?=.)a[^/]*?[^/]*?[^/]*?c)$/',
|
||||
'/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]c)$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/])$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/])$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/][^/]*?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/]b)$/',
|
||||
'/^(?:(?=.)#[^/]*?)$/',
|
||||
'/^(?!^(?:(?=.)a[^/]*?)$).*$/',
|
||||
'/^(?:(?=.)\\!a[^/]*?)$/',
|
||||
'/^(?:(?=.)a[^/]*?)$/',
|
||||
'/^(?!^(?:(?=.)\\!a[^/]*?)$).*$/',
|
||||
'/^(?:(?!\\.)(?=.)[^/]*?\\.(?:(?!js)[^/]*?))$/',
|
||||
'/^(?:(?:(?!(?:\\/|^)\\.).)*?\\/\\.x\\/(?:(?!(?:\\/|^)\\.).)*?)$/' ]
|
||||
var re = 0;
|
||||
|
||||
tap.test("basic tests", function (t) {
|
||||
var start = Date.now()
|
||||
|
||||
// [ pattern, [matches], MM opts, files, TAP opts]
|
||||
patterns.forEach(function (c) {
|
||||
if (typeof c === "function") return c()
|
||||
if (typeof c === "string") return t.comment(c)
|
||||
|
||||
var pattern = c[0]
|
||||
, expect = c[1].sort(alpha)
|
||||
, options = c[2] || {}
|
||||
, f = c[3] || files
|
||||
, tapOpts = c[4] || {}
|
||||
|
||||
// options.debug = true
|
||||
var m = new mm.Minimatch(pattern, options)
|
||||
var r = m.makeRe()
|
||||
var expectRe = regexps[re++]
|
||||
tapOpts.re = String(r) || JSON.stringify(r)
|
||||
tapOpts.files = JSON.stringify(f)
|
||||
tapOpts.pattern = pattern
|
||||
tapOpts.set = m.set
|
||||
tapOpts.negated = m.negate
|
||||
|
||||
var actual = mm.match(f, pattern, options)
|
||||
actual.sort(alpha)
|
||||
|
||||
t.equivalent( actual, expect
|
||||
, JSON.stringify(pattern) + " " + JSON.stringify(expect)
|
||||
, tapOpts )
|
||||
|
||||
t.equal(tapOpts.re, expectRe, tapOpts)
|
||||
})
|
||||
|
||||
t.comment("time=" + (Date.now() - start) + "ms")
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test("global leak test", function (t) {
|
||||
var globalAfter = Object.keys(global)
|
||||
t.equivalent(globalAfter, globalBefore, "no new globals, please")
|
||||
t.end()
|
||||
})
|
||||
|
||||
function alpha (a, b) {
|
||||
return a > b ? 1 : -1
|
||||
}
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
var tap = require("tap")
|
||||
, minimatch = require("../")
|
||||
|
||||
tap.test("brace expansion", function (t) {
|
||||
// [ pattern, [expanded] ]
|
||||
; [ [ "a{b,c{d,e},{f,g}h}x{y,z}"
|
||||
, [ "abxy"
|
||||
, "abxz"
|
||||
, "acdxy"
|
||||
, "acdxz"
|
||||
, "acexy"
|
||||
, "acexz"
|
||||
, "afhxy"
|
||||
, "afhxz"
|
||||
, "aghxy"
|
||||
, "aghxz" ] ]
|
||||
, [ "a{1..5}b"
|
||||
, [ "a1b"
|
||||
, "a2b"
|
||||
, "a3b"
|
||||
, "a4b"
|
||||
, "a5b" ] ]
|
||||
, [ "a{b}c", ["a{b}c"] ]
|
||||
].forEach(function (tc) {
|
||||
var p = tc[0]
|
||||
, expect = tc[1]
|
||||
t.equivalent(minimatch.braceExpand(p), expect, p)
|
||||
})
|
||||
console.error("ending")
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
var Minimatch = require("../minimatch.js").Minimatch
|
||||
var tap = require("tap")
|
||||
tap.test("cache test", function (t) {
|
||||
var mm1 = new Minimatch("a?b")
|
||||
var mm2 = new Minimatch("a?b")
|
||||
t.equal(mm1, mm2, "should get the same object")
|
||||
// the lru should drop it after 100 entries
|
||||
for (var i = 0; i < 100; i ++) {
|
||||
new Minimatch("a"+i)
|
||||
}
|
||||
mm2 = new Minimatch("a?b")
|
||||
t.notEqual(mm1, mm2, "cache should have dropped")
|
||||
t.end()
|
||||
})
|
||||
Generated
Vendored
+274
@@ -0,0 +1,274 @@
|
||||
// http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test
|
||||
//
|
||||
// TODO: Some of these tests do very bad things with backslashes, and will
|
||||
// most likely fail badly on windows. They should probably be skipped.
|
||||
|
||||
var tap = require("tap")
|
||||
, globalBefore = Object.keys(global)
|
||||
, mm = require("../")
|
||||
, files = [ "a", "b", "c", "d", "abc"
|
||||
, "abd", "abe", "bb", "bcd"
|
||||
, "ca", "cb", "dd", "de"
|
||||
, "bdir/", "bdir/cfile"]
|
||||
, next = files.concat([ "a-b", "aXb"
|
||||
, ".x", ".y" ])
|
||||
|
||||
tap.test("basic tests", function (t) {
|
||||
var start = Date.now()
|
||||
|
||||
// [ pattern, [matches], MM opts, files, TAP opts]
|
||||
; [ "http://www.bashcookbook.com/bashinfo" +
|
||||
"/source/bash-1.14.7/tests/glob-test"
|
||||
, ["a*", ["a", "abc", "abd", "abe"]]
|
||||
, ["X*", ["X*"], {nonull: true}]
|
||||
|
||||
// allow null glob expansion
|
||||
, ["X*", []]
|
||||
|
||||
// isaacs: Slightly different than bash/sh/ksh
|
||||
// \\* is not un-escaped to literal "*" in a failed match,
|
||||
// but it does make it get treated as a literal star
|
||||
, ["\\*", ["\\*"], {nonull: true}]
|
||||
, ["\\**", ["\\**"], {nonull: true}]
|
||||
, ["\\*\\*", ["\\*\\*"], {nonull: true}]
|
||||
|
||||
, ["b*/", ["bdir/"]]
|
||||
, ["c*", ["c", "ca", "cb"]]
|
||||
, ["**", files]
|
||||
|
||||
, ["\\.\\./*/", ["\\.\\./*/"], {nonull: true}]
|
||||
, ["s/\\..*//", ["s/\\..*//"], {nonull: true}]
|
||||
|
||||
, "legendary larry crashes bashes"
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/"
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/"], {nonull: true}]
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/"
|
||||
, ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/"], {nonull: true}]
|
||||
|
||||
, "character classes"
|
||||
, ["[a-c]b*", ["abc", "abd", "abe", "bb", "cb"]]
|
||||
, ["[a-y]*[^c]", ["abd", "abe", "bb", "bcd",
|
||||
"bdir/", "ca", "cb", "dd", "de"]]
|
||||
, ["a*[^c]", ["abd", "abe"]]
|
||||
, function () { files.push("a-b", "aXb") }
|
||||
, ["a[X-]b", ["a-b", "aXb"]]
|
||||
, function () { files.push(".x", ".y") }
|
||||
, ["[^a-c]*", ["d", "dd", "de"]]
|
||||
, function () { files.push("a*b/", "a*b/ooo") }
|
||||
, ["a\\*b/*", ["a*b/ooo"]]
|
||||
, ["a\\*?/*", ["a*b/ooo"]]
|
||||
, ["*\\\\!*", [], {null: true}, ["echo !7"]]
|
||||
, ["*\\!*", ["echo !7"], null, ["echo !7"]]
|
||||
, ["*.\\*", ["r.*"], null, ["r.*"]]
|
||||
, ["a[b]c", ["abc"]]
|
||||
, ["a[\\b]c", ["abc"]]
|
||||
, ["a?c", ["abc"]]
|
||||
, ["a\\*c", [], {null: true}, ["abc"]]
|
||||
, ["", [""], { null: true }, [""]]
|
||||
|
||||
, "http://www.opensource.apple.com/source/bash/bash-23/" +
|
||||
"bash/tests/glob-test"
|
||||
, function () { files.push("man/", "man/man1/", "man/man1/bash.1") }
|
||||
, ["*/man*/bash.*", ["man/man1/bash.1"]]
|
||||
, ["man/man1/bash.1", ["man/man1/bash.1"]]
|
||||
, ["a***c", ["abc"], null, ["abc"]]
|
||||
, ["a*****?c", ["abc"], null, ["abc"]]
|
||||
, ["?*****??", ["abc"], null, ["abc"]]
|
||||
, ["*****??", ["abc"], null, ["abc"]]
|
||||
, ["?*****?c", ["abc"], null, ["abc"]]
|
||||
, ["?***?****c", ["abc"], null, ["abc"]]
|
||||
, ["?***?****?", ["abc"], null, ["abc"]]
|
||||
, ["?***?****", ["abc"], null, ["abc"]]
|
||||
, ["*******c", ["abc"], null, ["abc"]]
|
||||
, ["*******?", ["abc"], null, ["abc"]]
|
||||
, ["a*cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??k***", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??***k", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a**?**cd**?**??***k**", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["a****c**?**??*****", ["abcdecdhjk"], null, ["abcdecdhjk"]]
|
||||
, ["[-abc]", ["-"], null, ["-"]]
|
||||
, ["[abc-]", ["-"], null, ["-"]]
|
||||
, ["\\", ["\\"], null, ["\\"]]
|
||||
, ["[\\\\]", ["\\"], null, ["\\"]]
|
||||
, ["[[]", ["["], null, ["["]]
|
||||
, ["[", ["["], null, ["["]]
|
||||
, ["[*", ["[abc"], null, ["[abc"]]
|
||||
, "a right bracket shall lose its special meaning and\n" +
|
||||
"represent itself in a bracket expression if it occurs\n" +
|
||||
"first in the list. -- POSIX.2 2.8.3.2"
|
||||
, ["[]]", ["]"], null, ["]"]]
|
||||
, ["[]-]", ["]"], null, ["]"]]
|
||||
, ["[a-\z]", ["p"], null, ["p"]]
|
||||
, ["??**********?****?", [], { null: true }, ["abc"]]
|
||||
, ["??**********?****c", [], { null: true }, ["abc"]]
|
||||
, ["?************c****?****", [], { null: true }, ["abc"]]
|
||||
, ["*c*?**", [], { null: true }, ["abc"]]
|
||||
, ["a*****c*?**", [], { null: true }, ["abc"]]
|
||||
, ["a********???*******", [], { null: true }, ["abc"]]
|
||||
, ["[]", [], { null: true }, ["a"]]
|
||||
, ["[abc", [], { null: true }, ["["]]
|
||||
|
||||
, "nocase tests"
|
||||
, ["XYZ", ["xYz"], { nocase: true, null: true }
|
||||
, ["xYz", "ABC", "IjK"]]
|
||||
, ["ab*", ["ABC"], { nocase: true, null: true }
|
||||
, ["xYz", "ABC", "IjK"]]
|
||||
, ["[ia]?[ck]", ["ABC", "IjK"], { nocase: true, null: true }
|
||||
, ["xYz", "ABC", "IjK"]]
|
||||
|
||||
// [ pattern, [matches], MM opts, files, TAP opts]
|
||||
, "onestar/twostar"
|
||||
, ["{/*,*}", [], {null: true}, ["/asdf/asdf/asdf"]]
|
||||
, ["{/?,*}", ["/a", "bb"], {null: true}
|
||||
, ["/a", "/b/b", "/a/b/c", "bb"]]
|
||||
|
||||
, "dots should not match unless requested"
|
||||
, ["**", ["a/b"], {}, ["a/b", "a/.d", ".a/.d"]]
|
||||
|
||||
// .. and . can only match patterns starting with .,
|
||||
// even when options.dot is set.
|
||||
, function () {
|
||||
files = ["a/./b", "a/../b", "a/c/b", "a/.d/b"]
|
||||
}
|
||||
, ["a/*/b", ["a/c/b", "a/.d/b"], {dot: true}]
|
||||
, ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: true}]
|
||||
, ["a/*/b", ["a/c/b"], {dot:false}]
|
||||
, ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: false}]
|
||||
|
||||
|
||||
// this also tests that changing the options needs
|
||||
// to change the cache key, even if the pattern is
|
||||
// the same!
|
||||
, ["**", ["a/b","a/.d",".a/.d"], { dot: true }
|
||||
, [ ".a/.d", "a/.d", "a/b"]]
|
||||
|
||||
, "paren sets cannot contain slashes"
|
||||
, ["*(a/b)", ["*(a/b)"], {nonull: true}, ["a/b"]]
|
||||
|
||||
// brace sets trump all else.
|
||||
//
|
||||
// invalid glob pattern. fails on bash4 and bsdglob.
|
||||
// however, in this implementation, it's easier just
|
||||
// to do the intuitive thing, and let brace-expansion
|
||||
// actually come before parsing any extglob patterns,
|
||||
// like the documentation seems to say.
|
||||
//
|
||||
// XXX: if anyone complains about this, either fix it
|
||||
// or tell them to grow up and stop complaining.
|
||||
//
|
||||
// bash/bsdglob says this:
|
||||
// , ["*(a|{b),c)}", ["*(a|{b),c)}"], {}, ["a", "ab", "ac", "ad"]]
|
||||
// but we do this instead:
|
||||
, ["*(a|{b),c)}", ["a", "ab", "ac"], {}, ["a", "ab", "ac", "ad"]]
|
||||
|
||||
// test partial parsing in the presence of comment/negation chars
|
||||
, ["[!a*", ["[!ab"], {}, ["[!ab", "[ab"]]
|
||||
, ["[#a*", ["[#ab"], {}, ["[#ab", "[ab"]]
|
||||
|
||||
// like: {a,b|c\\,d\\\|e} except it's unclosed, so it has to be escaped.
|
||||
, ["+(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g"
|
||||
, ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g"]
|
||||
, {}
|
||||
, ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g", "a", "b\\c"]]
|
||||
|
||||
|
||||
// crazy nested {,,} and *(||) tests.
|
||||
, function () {
|
||||
files = [ "a", "b", "c", "d"
|
||||
, "ab", "ac", "ad"
|
||||
, "bc", "cb"
|
||||
, "bc,d", "c,db", "c,d"
|
||||
, "d)", "(b|c", "*(b|c"
|
||||
, "b|c", "b|cc", "cb|c"
|
||||
, "x(a|b|c)", "x(a|c)"
|
||||
, "(a|b|c)", "(a|c)"]
|
||||
}
|
||||
, ["*(a|{b,c})", ["a", "b", "c", "ab", "ac"]]
|
||||
, ["{a,*(b|c,d)}", ["a","(b|c", "*(b|c", "d)"]]
|
||||
// a
|
||||
// *(b|c)
|
||||
// *(b|d)
|
||||
, ["{a,*(b|{c,d})}", ["a","b", "bc", "cb", "c", "d"]]
|
||||
, ["*(a|{b|c,c})", ["a", "b", "c", "ab", "ac", "bc", "cb"]]
|
||||
|
||||
|
||||
// test various flag settings.
|
||||
, [ "*(a|{b|c,c})", ["x(a|b|c)", "x(a|c)", "(a|b|c)", "(a|c)"]
|
||||
, { noext: true } ]
|
||||
, ["a?b", ["x/y/acb", "acb/"], {matchBase: true}
|
||||
, ["x/y/acb", "acb/", "acb/d/e", "x/y/acb/d"] ]
|
||||
, ["#*", ["#a", "#b"], {nocomment: true}, ["#a", "#b", "c#d"]]
|
||||
|
||||
|
||||
// begin channelling Boole and deMorgan...
|
||||
, "negation tests"
|
||||
, function () {
|
||||
files = ["d", "e", "!ab", "!abc", "a!b", "\\!a"]
|
||||
}
|
||||
|
||||
// anything that is NOT a* matches.
|
||||
, ["!a*", ["\\!a", "d", "e", "!ab", "!abc"]]
|
||||
|
||||
// anything that IS !a* matches.
|
||||
, ["!a*", ["!ab", "!abc"], {nonegate: true}]
|
||||
|
||||
// anything that IS a* matches
|
||||
, ["!!a*", ["a!b"]]
|
||||
|
||||
// anything that is NOT !a* matches
|
||||
, ["!\\!a*", ["a!b", "d", "e", "\\!a"]]
|
||||
|
||||
// negation nestled within a pattern
|
||||
, function () {
|
||||
files = [ "foo.js"
|
||||
, "foo.bar"
|
||||
// can't match this one without negative lookbehind.
|
||||
, "foo.js.js"
|
||||
, "blar.js"
|
||||
, "foo."
|
||||
, "boo.js.boo" ]
|
||||
}
|
||||
, ["*.!(js)", ["foo.bar", "foo.", "boo.js.boo"] ]
|
||||
|
||||
].forEach(function (c) {
|
||||
if (typeof c === "function") return c()
|
||||
if (typeof c === "string") return t.comment(c)
|
||||
|
||||
var pattern = c[0]
|
||||
, expect = c[1].sort(alpha)
|
||||
, options = c[2] || {}
|
||||
, f = c[3] || files
|
||||
, tapOpts = c[4] || {}
|
||||
|
||||
// options.debug = true
|
||||
var Class = mm.defaults(options).Minimatch
|
||||
var m = new Class(pattern, {})
|
||||
var r = m.makeRe()
|
||||
tapOpts.re = String(r) || JSON.stringify(r)
|
||||
tapOpts.files = JSON.stringify(f)
|
||||
tapOpts.pattern = pattern
|
||||
tapOpts.set = m.set
|
||||
tapOpts.negated = m.negate
|
||||
|
||||
var actual = mm.match(f, pattern, options)
|
||||
actual.sort(alpha)
|
||||
|
||||
t.equivalent( actual, expect
|
||||
, JSON.stringify(pattern) + " " + JSON.stringify(expect)
|
||||
, tapOpts )
|
||||
})
|
||||
|
||||
t.comment("time=" + (Date.now() - start) + "ms")
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test("global leak test", function (t) {
|
||||
var globalAfter = Object.keys(global)
|
||||
t.equivalent(globalAfter, globalBefore, "no new globals, please")
|
||||
t.end()
|
||||
})
|
||||
|
||||
function alpha (a, b) {
|
||||
return a > b ? 1 : -1
|
||||
}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
var test = require('tap').test
|
||||
var minimatch = require('../')
|
||||
|
||||
test('extglob ending with statechar', function(t) {
|
||||
t.notOk(minimatch('ax', 'a?(b*)'))
|
||||
t.ok(minimatch('ax', '?(a*|b)'))
|
||||
t.end()
|
||||
})
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"vow-fs@0.3.2",
|
||||
"/mnt/data/Sites/r2c.net/user/themes/r2c"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "vow-fs@0.3.2",
|
||||
"_id": "vow-fs@0.3.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-6isDTYXh24wnfrLpqG0cFfXTjno=",
|
||||
"_location": "/vow-fs",
|
||||
"_phantomChildren": {
|
||||
"inherits": "2.0.3",
|
||||
"lru-cache": "2.7.3",
|
||||
"sigmund": "1.0.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "vow-fs@0.3.2",
|
||||
"name": "vow-fs",
|
||||
"escapedName": "vow-fs",
|
||||
"rawSpec": "0.3.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.3.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/csscomb-core"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/vow-fs/-/vow-fs-0.3.2.tgz",
|
||||
"_spec": "0.3.2",
|
||||
"_where": "/mnt/data/Sites/r2c.net/user/themes/r2c",
|
||||
"author": {
|
||||
"name": "Dmitry Filatov",
|
||||
"email": "dfilatov@yandex-team.ru"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/dfilatov/vow-fs/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Dmitry Filatov",
|
||||
"email": "dfilatov@yandex-team.ru"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"glob": "3.2.8",
|
||||
"node-uuid": "1.4.0",
|
||||
"vow": "0.4.4",
|
||||
"vow-queue": "0.3.1"
|
||||
},
|
||||
"description": "File I/O by Vow",
|
||||
"devDependencies": {
|
||||
"istanbul": "",
|
||||
"nodeunit": ""
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/dfilatov/vow-fs",
|
||||
"keywords": [
|
||||
"vow",
|
||||
"promise",
|
||||
"file system"
|
||||
],
|
||||
"main": "lib/fs",
|
||||
"name": "vow-fs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/dfilatov/vow-fs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/istanbul/lib/cli.js test test/runner.js"
|
||||
},
|
||||
"version": "0.3.2"
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
vfs = require('../lib/fs'),
|
||||
TEST_DIR = path.join(__dirname, 'test-dir');
|
||||
|
||||
module.exports = {
|
||||
setUp : function(done) {
|
||||
fs.mkdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
tearDown : function(done) {
|
||||
fs.rmdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
'should copy file' : function(test) {
|
||||
var sourceFile = path.join(TEST_DIR, 'source-file'),
|
||||
targetFile = path.join(TEST_DIR, 'target-file');
|
||||
fs.writeFileSync(sourceFile, 'source');
|
||||
vfs.copy(sourceFile, targetFile)
|
||||
.then(function() {
|
||||
test.equal(fs.readFileSync(targetFile, 'utf8'), 'source');
|
||||
})
|
||||
.always(function() {
|
||||
fs.unlinkSync(sourceFile);
|
||||
fs.unlinkSync(targetFile);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should copy file if target exists' : function(test) {
|
||||
var sourceFile = path.join(TEST_DIR, 'source-file'),
|
||||
targetFile = path.join(TEST_DIR, 'target-file');
|
||||
fs.writeFileSync(sourceFile, 'source');
|
||||
fs.writeFileSync(targetFile, 'target');
|
||||
vfs.copy(sourceFile, targetFile)
|
||||
.then(function() {
|
||||
test.equal(fs.readFileSync(targetFile, 'utf8'), 'source');
|
||||
})
|
||||
.always(function() {
|
||||
fs.unlinkSync(sourceFile);
|
||||
fs.unlinkSync(targetFile);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should not copy file if source is directory' : function(test) {
|
||||
var sourceDir = path.join(TEST_DIR, 'source-dir'),
|
||||
targetFile = path.join(TEST_DIR, 'target-file');
|
||||
fs.mkdirSync(sourceDir);
|
||||
vfs.copy(sourceDir, targetFile)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(false);
|
||||
},
|
||||
function(err) {
|
||||
test.equal(err.code, 'EISDIR');
|
||||
})
|
||||
.always(function() {
|
||||
fs.rmdirSync(sourceDir);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should not copy file if target is directory' : function(test) {
|
||||
var sourceFile = path.join(TEST_DIR, 'source-file'),
|
||||
targetDir = path.join(TEST_DIR, 'target-dir');
|
||||
fs.writeFileSync(sourceFile, 'source');
|
||||
fs.mkdirSync(targetDir);
|
||||
vfs.copy(sourceFile, targetDir)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(false);
|
||||
},
|
||||
function(err) {
|
||||
test.equal(err.code, 'EISDIR');
|
||||
})
|
||||
.always(function() {
|
||||
fs.unlinkSync(sourceFile);
|
||||
fs.rmdirSync(targetDir);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should not copy if target not exists' : function(test) {
|
||||
var sourceFile = path.join(TEST_DIR, 'source-file'),
|
||||
targetFile = path.join(TEST_DIR, 'target-file');
|
||||
vfs.copy(sourceFile, targetFile)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(false);
|
||||
},
|
||||
function(err) {
|
||||
test.equal(err.code, 'ENOENT');
|
||||
})
|
||||
.always(function() {
|
||||
test.done();
|
||||
});
|
||||
}
|
||||
};
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
vfs = require('../lib/fs'),
|
||||
TEST_DIR = path.join(__dirname, 'test-dir');
|
||||
|
||||
module.exports = {
|
||||
setUp : function(done) {
|
||||
fs.mkdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
tearDown : function(done) {
|
||||
fs.rmdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
'should return true if the file is a symbolic link' : function(test) {
|
||||
var sourceFile = path.join(TEST_DIR, 'source-file'),
|
||||
targetFile = path.join(TEST_DIR, 'target-file');
|
||||
fs.writeFileSync(sourceFile, 'source');
|
||||
fs.symlinkSync(sourceFile, targetFile);
|
||||
vfs.isSymLink(targetFile)
|
||||
.then(function(isSymLink) {
|
||||
test.ok(isSymLink);
|
||||
})
|
||||
.always(function() {
|
||||
fs.unlinkSync(sourceFile);
|
||||
fs.unlinkSync(targetFile);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should return false if the file is not a symbolic link' : function(test) {
|
||||
var sourceFile = path.join(TEST_DIR, 'source-file');
|
||||
fs.writeFileSync(sourceFile, 'source');
|
||||
vfs.isSymLink(sourceFile)
|
||||
.then(function(isSymLink) {
|
||||
test.ok(!isSymLink);
|
||||
})
|
||||
.always(function() {
|
||||
fs.unlinkSync(sourceFile);
|
||||
test.done();
|
||||
});
|
||||
}
|
||||
};
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
vfs = require('../lib/fs'),
|
||||
TEST_DIR = path.join(__dirname, 'test-dir');
|
||||
|
||||
module.exports = {
|
||||
setUp : function(done) {
|
||||
fs.mkdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
tearDown : function(done) {
|
||||
fs.rmdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
'should make directory' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'a');
|
||||
vfs.makeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
return vfs.exists(dir);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
})
|
||||
.always(function(promise) {
|
||||
test.ok(promise.valueOf());
|
||||
test.ok(fs.statSync(dir).isDirectory());
|
||||
fs.rmdirSync(dir);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should make directory if exists' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'a');
|
||||
fs.mkdirSync(dir);
|
||||
vfs.makeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
return vfs.exists(dir);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
})
|
||||
.always(function(promise) {
|
||||
test.ok(promise.valueOf());
|
||||
test.ok(fs.statSync(dir).isDirectory());
|
||||
fs.rmdirSync(dir);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should be failed if directory exists' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'a');
|
||||
fs.mkdirSync(dir);
|
||||
vfs.makeDir(dir, true)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(false);
|
||||
},
|
||||
function() {
|
||||
test.ok(true);
|
||||
})
|
||||
.always(function() {
|
||||
fs.rmdirSync(dir);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should be failed if file with same name exists' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'test-file');
|
||||
fs.writeFileSync(dir, 'test');
|
||||
vfs.makeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(false);
|
||||
},
|
||||
function() {
|
||||
test.ok(true);
|
||||
})
|
||||
.always(function() {
|
||||
fs.unlinkSync(path.join(TEST_DIR, 'test-file'));
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should make directory tree' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'a/b/c');
|
||||
vfs.makeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
return vfs.exists(dir);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
})
|
||||
.always(function(promise) {
|
||||
test.ok(promise.valueOf());
|
||||
test.ok(fs.statSync(dir).isDirectory());
|
||||
fs.rmdirSync(path.join(TEST_DIR, 'a/b/c'));
|
||||
fs.rmdirSync(path.join(TEST_DIR, 'a/b'));
|
||||
fs.rmdirSync(path.join(TEST_DIR, 'a'));
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should make directory tree if exists' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'a/b/c');
|
||||
fs.mkdirSync(path.join(TEST_DIR, 'a'));
|
||||
fs.mkdirSync(path.join(TEST_DIR, 'a', 'b'));
|
||||
fs.mkdirSync(dir);
|
||||
vfs.makeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(true);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
})
|
||||
.always(function() {
|
||||
fs.rmdirSync(path.join(TEST_DIR, 'a/b/c'));
|
||||
fs.rmdirSync(path.join(TEST_DIR, 'a/b'));
|
||||
fs.rmdirSync(path.join(TEST_DIR, 'a'));
|
||||
test.done();
|
||||
});
|
||||
}
|
||||
};
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
os = require('os'),
|
||||
vfs = require('../lib/fs'),
|
||||
tmpDir = os.tmpdir || os.tmpDir || function() { return '/tmp'; },
|
||||
TEST_DIR = path.join(__dirname, 'test-dir');
|
||||
|
||||
module.exports = {
|
||||
setUp : function(done) {
|
||||
fs.mkdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
tearDown : function(done) {
|
||||
fs.rmdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
'should make temporary file with default options' : function(test) {
|
||||
var filePath;
|
||||
vfs.makeTmpFile()
|
||||
.then(
|
||||
function(_filePath) {
|
||||
return vfs.exists(filePath = _filePath);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
throw Error();
|
||||
})
|
||||
.then(function(exists) {
|
||||
fs.unlinkSync(filePath);
|
||||
test.strictEqual(path.dirname(filePath), path.resolve(tmpDir()));
|
||||
test.strictEqual(path.extname(filePath), '.tmp');
|
||||
test.ok(exists);
|
||||
})
|
||||
.always(function() {
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should make temporary file in custom directory' : function(test) {
|
||||
var filePath;
|
||||
vfs.makeTmpFile({ dir : TEST_DIR })
|
||||
.then(
|
||||
function(_filePath) {
|
||||
return vfs.exists(filePath = _filePath);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
throw Error();
|
||||
})
|
||||
.then(function(exists) {
|
||||
fs.unlinkSync(filePath);
|
||||
test.ok(exists);
|
||||
test.strictEqual(path.dirname(filePath), TEST_DIR);
|
||||
})
|
||||
.always(function() {
|
||||
test.done();
|
||||
})
|
||||
},
|
||||
|
||||
'should make temporary file with custom prefix' : function(test) {
|
||||
var filePath;
|
||||
vfs.makeTmpFile({ prefix : '__prefix' })
|
||||
.then(
|
||||
function(_filePath) {
|
||||
return vfs.exists(filePath = _filePath);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
throw Error();
|
||||
})
|
||||
.then(function(exists) {
|
||||
fs.unlinkSync(filePath);
|
||||
test.ok(exists);
|
||||
test.ok(filePath.indexOf('__prefix') > -1);
|
||||
})
|
||||
.always(function() {
|
||||
test.done();
|
||||
})
|
||||
},
|
||||
|
||||
'should make temporary file with custom extension' : function(test) {
|
||||
var filePath;
|
||||
vfs.makeTmpFile({ ext : '.css' })
|
||||
.then(
|
||||
function(_filePath) {
|
||||
return vfs.exists(filePath = _filePath);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
throw Error();
|
||||
})
|
||||
.then(function(exists) {
|
||||
fs.unlinkSync(filePath);
|
||||
test.ok(exists);
|
||||
test.strictEqual(path.extname(filePath), '.css');
|
||||
})
|
||||
.always(function() {
|
||||
test.done();
|
||||
})
|
||||
}
|
||||
};
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
vfs = require('../lib/fs'),
|
||||
TEST_DIR = path.join(__dirname, 'test-dir');
|
||||
|
||||
module.exports = {
|
||||
setUp : function(done) {
|
||||
fs.mkdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
tearDown : function(done) {
|
||||
fs.rmdirSync(TEST_DIR);
|
||||
done();
|
||||
},
|
||||
|
||||
'should remove empty directory' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'dir');
|
||||
fs.mkdirSync(dir);
|
||||
vfs.removeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
return vfs.exists(dir);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
})
|
||||
.always(function(promise) {
|
||||
test.ok(!promise.valueOf());
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should remove directory tree' : function(test) {
|
||||
var dir = path.join(TEST_DIR, 'dir');
|
||||
fs.mkdirSync(dir);
|
||||
fs.mkdirSync(path.join(dir, 'a'));
|
||||
fs.writeFileSync(path.join(dir, 'a', 'file'), 'file');
|
||||
fs.mkdirSync(path.join(dir, 'a', 'b'));
|
||||
fs.writeFileSync(path.join(dir, 'a', 'b', 'file1'), 'file1');
|
||||
fs.writeFileSync(path.join(dir, 'a', 'b', 'file2'), 'file2');
|
||||
vfs.removeDir(dir)
|
||||
.then(
|
||||
function() {
|
||||
return vfs.exists(dir);
|
||||
},
|
||||
function() {
|
||||
test.ok(false);
|
||||
})
|
||||
.always(function(promise) {
|
||||
test.ok(!promise.valueOf());
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'should not remove file' : function(test) {
|
||||
var filePath = path.join(TEST_DIR, 'file');
|
||||
fs.writeFileSync(filePath, 'file');
|
||||
vfs.removeDir(filePath)
|
||||
.then(
|
||||
function() {
|
||||
test.ok(false);
|
||||
},
|
||||
function(err) {
|
||||
test.equal(err.code, 'ENOTDIR');
|
||||
return vfs.exists(filePath);
|
||||
})
|
||||
.always(function(promise) {
|
||||
test.ok(promise.valueOf());
|
||||
fs.unlinkSync(filePath);
|
||||
test.done();
|
||||
});
|
||||
}
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path');
|
||||
|
||||
require('nodeunit').reporters.default.run(
|
||||
fs.readdirSync(__dirname)
|
||||
.filter(function(file){
|
||||
return fs.statSync(path.join(__dirname, file)).isFile() && file !== 'runner.js';
|
||||
})
|
||||
.map(function(file) {
|
||||
return path.join('test', file);
|
||||
}),
|
||||
null,
|
||||
function(err) {
|
||||
err && process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user