use micromatch
This commit is contained in:
@ -11,10 +11,9 @@ const MAX_PARALLEL = 4;
|
|||||||
const proc = require('child_process');
|
const proc = require('child_process');
|
||||||
const { PassThrough } = require('stream');
|
const { PassThrough } = require('stream');
|
||||||
const events = require('events');
|
const events = require('events');
|
||||||
|
const micromatch = require('micromatch');
|
||||||
const limit = require('p-limit')(MAX_PARALLEL);
|
const limit = require('p-limit')(MAX_PARALLEL);
|
||||||
|
|
||||||
const strToRegex = str => new RegExp(`^${str.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/[*]/g, '.$&')}$`);
|
|
||||||
|
|
||||||
let [, , request = '', ...extraOptions] = process.argv;
|
let [, , request = '', ...extraOptions] = process.argv;
|
||||||
if (request.startsWith('-')) {
|
if (request.startsWith('-')) {
|
||||||
extraOptions.unshift(request);
|
extraOptions.unshift(request);
|
||||||
@ -23,8 +22,8 @@ if (request.startsWith('-')) {
|
|||||||
const [reqSpec, reqContract] = request.split(':').reverse();
|
const [reqSpec, reqContract] = request.split(':').reverse();
|
||||||
|
|
||||||
const specs = require(__dirname + '/specs.js')
|
const specs = require(__dirname + '/specs.js')
|
||||||
.filter(entry => !reqSpec || strToRegex(reqSpec).test(entry.spec))
|
.filter(entry => !reqSpec || micromatch(entry.spec, reqSpec))
|
||||||
.filter(entry => !reqContract || strToRegex(reqContract).test(entry.contract));
|
.filter(entry => !reqContract || micromatch(entry.contract, reqContract));
|
||||||
|
|
||||||
if (specs.length === 0) {
|
if (specs.length === 0) {
|
||||||
console.error(`Error: Requested spec '${request}' not found in specs.json`);
|
console.error(`Error: Requested spec '${request}' not found in specs.json`);
|
||||||
|
|||||||
Reference in New Issue
Block a user