Added some tests
This commit is contained in:
58
tests/node_modules/tape/bin/tape
generated
vendored
Executable file
58
tests/node_modules/tape/bin/tape
generated
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var resolveModule = require('resolve').sync;
|
||||
var resolvePath = require('path').resolve;
|
||||
var readFileSync = require('fs').readFileSync;
|
||||
var parseOpts = require('minimist');
|
||||
var glob = require('glob');
|
||||
var ignore = require('dotignore');
|
||||
|
||||
var opts = parseOpts(process.argv.slice(2), {
|
||||
alias: { r: 'require', i: 'ignore' },
|
||||
string: ['require', 'ignore'],
|
||||
default: { r: [], i: null }
|
||||
});
|
||||
|
||||
var cwd = process.cwd();
|
||||
|
||||
if (typeof opts.require === 'string') {
|
||||
opts.require = [opts.require];
|
||||
}
|
||||
|
||||
opts.require.forEach(function (module) {
|
||||
var options = { basedir: cwd, extensions: Object.keys(require.extensions) };
|
||||
if (module) {
|
||||
/* This check ensures we ignore `-r ""`, trailing `-r`, or
|
||||
* other silly things the user might (inadvertently) be doing.
|
||||
*/
|
||||
require(resolveModule(module, options));
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof opts.ignore === 'string') {
|
||||
try {
|
||||
var ignoreStr = readFileSync(resolvePath(cwd, opts.ignore || '.gitignore'), 'utf-8');
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
process.exit(2);
|
||||
}
|
||||
var matcher = ignore.createMatcher(ignoreStr);
|
||||
}
|
||||
|
||||
opts._.forEach(function (arg) {
|
||||
// If glob does not match, `files` will be an empty array.
|
||||
// Note: `glob.sync` may throw an error and crash the node process.
|
||||
var files = glob.sync(arg);
|
||||
|
||||
if (!Array.isArray(files)) {
|
||||
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
|
||||
}
|
||||
|
||||
files.filter(function (file) { return !matcher || !matcher.shouldIgnore(file); }).forEach(function (file) {
|
||||
require(resolvePath(cwd, file));
|
||||
});
|
||||
});
|
||||
|
||||
// vim: ft=javascript
|
||||
Reference in New Issue
Block a user