Comparing version 0.2.0 to 1.0.0
41
index.js
@@ -30,2 +30,11 @@ 'use strict'; | ||
function defaultHelperPatterns() { | ||
return [ | ||
'**/__tests__/helpers/**/*.js', | ||
'**/__tests__/**/_*.js', | ||
'**/test/helpers/**/*.js', | ||
'**/test/**/_*.js' | ||
]; | ||
} | ||
function AvaFiles(options) { | ||
@@ -38,5 +47,13 @@ if (!(this instanceof AvaFiles)) { | ||
var files = options.files; | ||
var files = (options.files || []).map(function (file) { | ||
// `./` should be removed from the beginning of patterns because | ||
// otherwise they won't match change events from Chokidar | ||
if (file.slice(0, 2) === './') { | ||
return file.slice(2); | ||
} | ||
if (!files || !files.length) { | ||
return file; | ||
}); | ||
if (!files.length) { | ||
files = defaultIncludePatterns(); | ||
@@ -63,2 +80,13 @@ } | ||
AvaFiles.prototype.findTestHelpers = function () { | ||
return handlePaths(defaultHelperPatterns(), ['!**/node_modules/**'], { | ||
cwd: this.cwd, | ||
includeUnderscoredFiles: true, | ||
cache: Object.create(null), | ||
statCache: Object.create(null), | ||
realpathCache: Object.create(null), | ||
symlinks: Object.create(null) | ||
}); | ||
}; | ||
function getDefaultIgnorePatterns() { | ||
@@ -263,4 +291,11 @@ return defaultIgnore.map(function (dir) { | ||
.filter(function (file) { | ||
return file && path.extname(file) === '.js' && path.basename(file)[0] !== '_'; | ||
return file && path.extname(file) === '.js'; | ||
}) | ||
.filter(function (file) { | ||
if (path.basename(file)[0] === '_' && globOptions.includeUnderscoredFiles !== true) { | ||
return false; | ||
} | ||
return true; | ||
}) | ||
.map(function (file) { | ||
@@ -267,0 +302,0 @@ return path.resolve(file); |
{ | ||
"name": "ava-files", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "File resolution for AVA", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -33,2 +33,6 @@ # ava-files [![Build Status](https://travis-ci.org/avajs/ava-files.svg?branch=master)](https://travis-ci.org/avajs/ava-files) [![Coverage Status](https://coveralls.io/repos/github/avajs/ava-files/badge.svg?branch=master)](https://coveralls.io/github/avajs/ava-files?branch=master) | ||
}); | ||
avaFiles.findTestHelpers().then(files => { | ||
// files is an array of found test helpers | ||
}); | ||
``` | ||
@@ -98,5 +102,9 @@ | ||
### avaFiles.findTestHelpers() | ||
Returns a `Promise` for an `Array` of `string` paths to the found helper files. | ||
## License | ||
MIT © [James Talmage](https://github.com/avajs) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12014
253
1
109