/** * Creates the function which checks whether a file path is matched with the given pattern or not. * * @param {string[]} includePatterns - The glob patterns to include files. * @param {string[]} excludePatterns - The glob patterns to exclude files. * @returns {function} Created predicate function. */ function createMatch(includePatterns, excludePatterns) { const include = includePatterns.map(pattern => new Minimatch(pattern)) const exclude = excludePatterns.map(pattern => new Minimatch(pattern)) return filePath => include.some(m => m.match(filePath)) && !exclude.some(m => m.match(filePath)) }
/** @typedef {import("../util/import-target")} ImportTarget */ /** * @typedef {Object} DefinitionData * @property {string | string[]} name The name to disallow. * @property {string} [message] The custom message to show. */ /** * Check if matched or not. * @param {InstanceType<Minimatch>} matcher The matcher. * @param {boolean} absolute The flag that the matcher is for absolute paths. * @param {ImportTarget} importee The importee information. */ function match(matcher, absolute, { filePath, name }) { if (absolute) { return filePath != null && matcher.match(filePath) } return matcher.match(name) }
it('Should fail if an item inside of the vector does not exist', (done) => { (async () => { const input = Input.create('input: filePath[]', {exists: true}); input.setValue([largeFilePath, largeFilePath, 'Fake!']); await input.validate(); })().then((result) => { done(new Error('Not Expected')); }).catch((err) => { done(minimatch(err.code, 'dedf89bc-c57a-4ce7-ab84-f84f49144230') ? null : err); }); });
function makeRules(patterns, dirRules, fileRules) { const rDir = /\/$/; const toRe = pattern => minimatch.makeRe(pattern); patterns && patterns.forEach(pattern => { if (rDir.test(pattern)) { pattern = pattern.replace(rDir, ''); dirRules.push(toRe(pattern)); } else { fileRules.push(toRe(pattern)); } }); }
gulp.task('unzip-7zip', function() { return gulp.src(zaZip) .pipe(unzip({ filter : function(entry) { return minimatch(entry.path, '**/7za.exe'); } })) .pipe(gulp.dest(config.buildFolderRoot)); });
function processGlobFilter(files, glob) { return files.filter(file => minimatch(file.filename, glob, { matchBase: true })); }
it('Should fail when trying to query for a registered reader', () => { try{ Mebo.Handler.registeredReader('EmptyHandler'); } catch(err){ if (!minimatch(err.message, 'Reader is not registered for handler *!')){ throw err; } } });
rules.map(rule => { if (typeof rule === 'string') { rule = minimatch.makeRe(rule); } return rule; })
it("Should fail in setupFrom to set a scalar input based on in a vector input without supplying 'at'", (done) => { const inputA = Input.create('input: filePath'); const inputB = Input.create('input: filePath[]'); try{ inputA.setupFrom(inputB); done(new Error('Unexpected result')); } catch(err){ done(minimatch(err.message, "Target input is not a vector, can't setup from a vector target input without supplying 'at'") ? null : err); } });
it('Should not be able to set a value in a read-only input', () => { let error = null; try{ const input = new Input('test'); input.setReadOnly(true); input.setValue(10); } catch(err){ error = err; } assert(minimatch(error.message, 'Input * is read only, cannot be modified!')); });
it('Should fail when querying a non-existing property', () => { let error = null; const input = new Input('inputName'); try{ input.property('non-existing'); } catch(err){ error = err; } assert(error); assert(minimatch(error.message, 'Property * is not registered!')); });
it('Should fail when assigning a non-existing property', () => { let error = null; const input = new Input('inputName'); try{ input.assignProperty('non-existing', 10); } catch(err){ error = err; } assert(error); assert(minimatch(error.message, 'Property * is not registered!')); });
function makeRules(patterns, dirRules, fileRules) { const rDir = /\/$/; const toRe = pattern => minimatch.makeRe(pattern); patterns && patterns.forEach(pattern => { if (rDir.test(pattern)) { pattern = pattern.replace(rDir, ''); dirRules.push(toRe(pattern)); } else { fileRules.push(toRe(pattern)); } }); }
rules.map(rule => { if (typeof rule === 'string') { rule = minimatch.makeRe(rule); } return rule; })
it("Should fail in setupFrom when 'at' is specified from a vector source input to a target vector input", (done) => { const inputA = Input.create('input: filePath[]'); const inputB = Input.create('input: filePath[]'); try{ inputA.setupFrom(inputB, 0); done(new Error('Unexpected result')); } catch(err){ done(minimatch(err.message, "Can't use at, from a source vector input to a target vector input") ? null : err); } });