mirror of
https://github.com/r0adkll/sign-android-release
synced 2026-09-30 16:48:45 +00:00
bump jest and make tests pass
This commit is contained in:
+31
-56
@@ -1,26 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
const { promisify } = require('util');
|
||||
const glob = promisify(require('glob'));
|
||||
const minimatch = require('minimatch');
|
||||
const readPkgUp = require('read-pkg-up');
|
||||
const requireMainFilename = require('require-main-filename');
|
||||
const { defaults } = require('@istanbuljs/schema');
|
||||
const isOutsideDir = require('./is-outside-dir');
|
||||
|
||||
class TestExclude {
|
||||
constructor(opts) {
|
||||
constructor(opts = {}) {
|
||||
Object.assign(
|
||||
this,
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
include: false,
|
||||
relativePath: true,
|
||||
configKey: null, // the key to load config from in package.json.
|
||||
configPath: null, // optionally override requireMainFilename.
|
||||
configFound: false,
|
||||
excludeNodeModules: true,
|
||||
extension: false
|
||||
},
|
||||
opts
|
||||
{relativePath: true},
|
||||
defaults.testExclude
|
||||
);
|
||||
|
||||
for (const [name, value] of Object.entries(opts)) {
|
||||
if (value !== undefined) {
|
||||
this[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof this.include === 'string') {
|
||||
this.include = [this.include];
|
||||
}
|
||||
@@ -31,21 +31,10 @@ class TestExclude {
|
||||
|
||||
if (typeof this.extension === 'string') {
|
||||
this.extension = [this.extension];
|
||||
} else if (
|
||||
!Array.isArray(this.extension) ||
|
||||
this.extension.length === 0
|
||||
) {
|
||||
} else if (this.extension.length === 0) {
|
||||
this.extension = false;
|
||||
}
|
||||
|
||||
if (!this.include && !this.exclude && this.configKey) {
|
||||
Object.assign(this, this.pkgConf(this.configKey, this.configPath));
|
||||
}
|
||||
|
||||
if (!this.exclude || !Array.isArray(this.exclude)) {
|
||||
this.exclude = exportFunc.defaultExclude;
|
||||
}
|
||||
|
||||
if (this.include && this.include.length > 0) {
|
||||
this.include = prepGlobPatterns([].concat(this.include));
|
||||
} else {
|
||||
@@ -99,7 +88,7 @@ class TestExclude {
|
||||
relFile = relFile || path.relative(this.cwd, filename);
|
||||
|
||||
// Don't instrument files that are outside of the current working directory.
|
||||
if (/^\.\./.test(path.relative(this.cwd, filename))) {
|
||||
if (isOutsideDir(this.cwd, filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -114,19 +103,6 @@ class TestExclude {
|
||||
);
|
||||
}
|
||||
|
||||
pkgConf(key, path) {
|
||||
const cwd = path || requireMainFilename(require);
|
||||
const obj = readPkgUp.sync({ cwd });
|
||||
|
||||
if (obj.pkg && obj.pkg[key] && typeof obj.pkg[key] === 'object') {
|
||||
this.configFound = true;
|
||||
|
||||
return obj.pkg[key];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
globSync(cwd = this.cwd) {
|
||||
const globPatterns = getExtensionPattern(this.extension || []);
|
||||
const globOptions = { cwd, nodir: true, dot: true };
|
||||
@@ -140,6 +116,19 @@ class TestExclude {
|
||||
.sync(globPatterns, globOptions)
|
||||
.filter(file => this.shouldInstrument(path.resolve(cwd, file)));
|
||||
}
|
||||
|
||||
async glob(cwd = this.cwd) {
|
||||
const globPatterns = getExtensionPattern(this.extension || []);
|
||||
const globOptions = { cwd, nodir: true, dot: true };
|
||||
/* If we don't have any excludeNegated then we can optimize glob by telling
|
||||
* it to not iterate into unwanted directory trees (like node_modules). */
|
||||
if (this.excludeNegated.length === 0) {
|
||||
globOptions.ignore = this.exclude;
|
||||
}
|
||||
|
||||
const list = await glob(globPatterns, globOptions);
|
||||
return list.filter(file => this.shouldInstrument(path.resolve(cwd, file)));
|
||||
}
|
||||
}
|
||||
|
||||
function prepGlobPatterns(patterns) {
|
||||
@@ -169,18 +158,4 @@ function getExtensionPattern(extension) {
|
||||
}
|
||||
}
|
||||
|
||||
const exportFunc = opts => new TestExclude(opts);
|
||||
|
||||
const devConfigs = ['ava', 'babel', 'jest', 'nyc', 'rollup', 'webpack'];
|
||||
|
||||
exportFunc.defaultExclude = [
|
||||
'coverage/**',
|
||||
'packages/*/test/**',
|
||||
'test/**',
|
||||
'test{,-*}.js',
|
||||
'**/*{.,-}test.js',
|
||||
'**/__tests__/**',
|
||||
`**/{${devConfigs.join()}}.config.js`
|
||||
];
|
||||
|
||||
module.exports = exportFunc;
|
||||
module.exports = TestExclude;
|
||||
|
||||
Reference in New Issue
Block a user