How to use normalizeGlobs method in ava

Best JavaScript code snippet using ava

index.js

Source:index.js Github

copy

Full Screen

...9 anymatch = require('anymatch'),10 pathIsAbsolute = require('path-is-absolute'),11 glob2base = require('glob2base'),12 Glob = require('glob').Glob;13function normalizeGlobs(globs) {14 if (!globs) throw new PluginError('gulp-watch', 'glob argument required');15 if (typeof globs === 'string') globs = [globs];16 if (!Array.isArray(globs)) {17 throw new PluginError('gulp-watch', 'glob should be String or Array, not ' + (typeof globs));18 }19 return globs;20}21module.exports = function (globs, opts, cb) {22 globs = normalizeGlobs(globs);23 if (typeof opts === 'function') {24 cb = opts;25 opts = {};26 }27 opts = opts || {};28 cb = cb || function () {};29 function resolveGlob(glob) {30 var mod = '',31 resolveFn = path.resolve;32 if (glob[0] === '!') {33 mod = glob[0];34 glob = glob.slice(1);35 }36 if (opts.cwd) {37 resolveFn = path.normalize;38 }39 return mod + resolveFn(glob);40 }41 globs = globs.map(resolveGlob);42 opts.events = opts.events || ['add', 'change', 'unlink'];43 if (opts.ignoreInitial === undefined) { opts.ignoreInitial = true; }44 opts.readDelay = opts.readDelay || 10;45 var baseForced = !!opts.base;46 var outputStream = new Duplex({objectMode: true, allowHalfOpen: true});47 outputStream._write = function _write(file, enc, done) {48 cb(file);49 outputStream.push(file);50 done();51 };52 outputStream._read = function _read() { };53 var watcher = chokidar.watch(globs, opts)54 .on('all', processEvent);55 ['add', 'change', 'unlink', 'addDir', 'unlinkDir', 'error', 'ready', 'raw']56 .forEach(function (ev) {57 watcher.on(ev, outputStream.emit.bind(outputStream, ev));58 });59 outputStream.add = function add(newGlobs) {60 newGlobs = normalizeGlobs(newGlobs)61 .map(resolveGlob);62 watcher.add(newGlobs);63 globs.push.apply(globs, newGlobs);64 };65 outputStream.unwatch = watcher.unwatch.bind(watcher);66 outputStream.close = function () {67 watcher.close();68 outputStream.emit('end');69 };70 function processEvent(event, filepath) {71 var glob = globs[anymatch(globs, filepath, true)];72 if (!baseForced) {73 opts.base = glob2base(new Glob(glob));74 }...

Full Screen

Full Screen

glob-utils.js

Source:glob-utils.js Github

copy

Full Screen

...46 * 47 * @param {...string} globs 48 * @returns {Array.<string>}49 */50function normalizeGlobs(...globs) {51 const ignoredGlobs = exports.applyIgnores();5253 /** @type {Array.<string>} */54 const gulpfiles =55 glob.sync(["**/gulpfile.js", "!./gulpfile.js", ...ignoredGlobs], { dot: true });5657 ignoredGlobs.push(...gulpfiles.map(((fileName) => "!" + path.join(path.dirname(fileName), "**", "*"))));5859 /** @type {Array.<string>} */60 const outputGlobs = [61 ...globs,62 ...ignoredGlobs63 ];6465 return outputGlobs;66}67exports.normalizeGlobs = normalizeGlobs;6869/**70 * 71 * @param {string} globlike 72 * @param {Array.<string>} [exts]73 * @returns {Array.<string>} 74 */75function toGlob(globlike, exts) {76 /** @type {Array.<string>} */77 const finalizedGlobs = [];7879 globlike = globlike80 .replace(/[\\|\/]/ig, path.sep)81 .replace(Regex.PathRef, (match, pathName) => configs.buildInfos.paths[pathName]);8283 if (Regex.GlobLike.test(globlike)) {84 finalizedGlobs.push(globlike);85 86 return finalizedGlobs;87 }8889 if (!exts || exts.length <= 0) {90 if (globlike.endsWith("/") || globlike.endsWith("\\")) {91 finalizedGlobs.push(globlike.substr(0, glob.length - 1));92 } else {93 finalizedGlobs.push(globlike);94 }9596 finalizedGlobs.push(path.join(globlike, "**", "*"));9798 } else {99 for (const ext of exts) {100 finalizedGlobs.push(path.join(globlike, "**", `*.${ext}`));101 }102 }103104 return finalizedGlobs;105}106107/**108 * 109 * @param {GlobLike} globlike 110 * @param {string | Array.<string>} [exts]111 * @returns {Array.<string>}112 */113function toGlobs(globlike, exts) {114 if (!globlike) {115 throw new Error("path must be provided");116 }117118 if (exts) {119 if (typeof exts === "string") {120 exts = [exts];121 } else if (!Array.isArray(exts)) {122 throw new Error("Unsupport value of param, exts");123 }124 }125126 if (typeof globlike === "string") {127 globlike = [globlike];128 } else if (!Array.isArray(globlike)) {129 throw new Error("Invalid value of param globlike. Only string | Array<string> is accepted.");130 }131132 /** @type {Array.<string>} */133 const results = [];134135 for (const globlikeItem of globlike) {136 // @ts-ignore137 const globs = toGlob(globlikeItem, exts);138139 results.push(...globs);140 }141142 return normalizeGlobs(...results);143} ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const ava = require('ava');2ava.normalizeGlobs(['test.js', 'test2.js']);3const ava = require('ava');4ava.normalizeGlobs(['test.js', 'test2.js']);5const ava = require('ava');6ava.normalizeGlobs(['test.js', 'test2.js']);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { normalizeGlobs } from 'ava/lib/cli';2const globs = normalizeGlobs(['test.js']);3console.log(globs);4import { normalizeGlobs } from 'ava/lib/cli';5const globs = normalizeGlobs(['test.js']);6console.log(globs);

Full Screen

Using AI Code Generation

copy

Full Screen

1const ava = require('ava');2const glob = ava.normalizeGlobs('test/test.js');3console.log(glob);4const ava = require('ava');5const glob = ava.normalizeGlobs('test/test.js');6console.log(glob);7const ava = require('ava');8const glob = ava.normalizeGlobs('test/test.js');9console.log(glob);10const ava = require('ava');11const glob = ava.normalizeGlobs('test/test.js');12console.log(glob);13const ava = require('ava');14const glob = ava.normalizeGlobs('test/test.js');15console.log(glob);16const ava = require('ava');17const glob = ava.normalizeGlobs('test/test.js');18console.log(glob);19const ava = require('ava');20const glob = ava.normalizeGlobs('test/test.js');21console.log(glob);22const ava = require('ava');23const glob = ava.normalizeGlobs('test/test.js');24console.log(glob);25const ava = require('ava');26const glob = ava.normalizeGlobs('test/test.js');27console.log(glob);28const ava = require('ava');29const glob = ava.normalizeGlobs('test/test.js');30console.log(glob);31const ava = require('ava');32const glob = ava.normalizeGlobs('test/test.js');33console.log(glob);34const ava = require('ava');35const glob = ava.normalizeGlobs('test/test.js');36console.log(glob);

Full Screen

Using AI Code Generation

copy

Full Screen

1const ava = require('ava');2const glob = ava.normalizeGlobs(['test/*.js']);3console.log(glob);4const ava = require('ava');5const glob = ava.normalizeGlobs(['test/*.js', 'test/**/*.js']);6console.log(glob);7const ava = require('ava');8const glob = ava.normalizeGlobs(['test/*.js', 'test/**/*.js', 'test/test.js']);9console.log(glob);10const ava = require('ava');11const glob = ava.normalizeGlobs(['test/*.js', 'test/**/*.js', 'test/test.js', 'test/test1.js']);12console.log(glob);13const ava = require('ava');14const glob = ava.normalizeGlobs(['test/*.js', 'test/**/*.js', 'test/test.js', 'test/test1.js', 'test/test2.js']);15console.log(glob);16const ava = require('ava');17const glob = ava.normalizeGlobs(['test/*.js', 'test/**/*.js', 'test/test.js', 'test/test1.js', 'test/test2.js', 'test/test3.js']);18console.log(glob);19const ava = require('ava');20const glob = ava.normalizeGlobs(['test/*.js', 'test/**/*.js

Full Screen

Using AI Code Generation

copy

Full Screen

1const globby = require('globby');2const test = require('ava');3test('test globby', t => {4 const globbyOptions = {5 };6 const glob = ['**/*.js', '!**/node_modules/**', '!**/fixtures/**', '!**/helpers/**'];7 const files = globby.sync(glob, globbyOptions);8 t.deepEqual(files, ['test.js']);9});10test('test ava', t => {11 const glob = ['**/*.js', '!**/node_modules/**', '!**/fixtures/**', '!**/helpers/**'];12 const files = test.normalizeGlobs(glob);13 t.deepEqual(files, ['test.js']);14});

Full Screen

Using AI Code Generation

copy

Full Screen

1const availableGlobs = require('available-globs');2const path = require('path');3const glob = require('glob');4const globOptions = {5 cwd: path.resolve(__dirname, 'test'),6};7const globArray = ['**/*.js'];8const normalizeGlobs = availableGlobs.normalizeGlobs;9const normalizedGlobs = normalizeGlobs(globArray, globOptions);10console.log(normalizedGlobs);11const availableGlobs = require('available-globs');12const path = require('path');13const glob = require('glob');14const globOptions = {15 cwd: path.resolve(__dirname, 'test'),16};17const globArray = ['**/*.js'];18const getGlobs = availableGlobs.getGlobs;19const globs = getGlobs(globArray, globOptions);20console.log(globs);21[MIT](LICENSE)

Full Screen

Using AI Code Generation

copy

Full Screen

1var availableGlobs = require('available-globs');2var globs = ['**/*.js', 'test/**/*'];3var normalizedGlobs = availableGlobs.normalizeGlobs(globs, {cwd: __dirname});4console.log(normalizedGlobs);5var availableGlobs = require('available-globs');6var globs = ['**/*.js', 'test/**/*'];7var normalizedGlobs = availableGlobs.normalizeGlobs(globs, {cwd: __dirname});8console.log(normalizedGlobs);9var availableGlobs = require('available-globs');10var globs = ['**/*.js', 'test/**/*'];11var normalizedGlobs = availableGlobs.normalizeGlobs(globs, {cwd: __dirname});12console.log(normalizedGlobs);13var availableGlobs = require('available-globs');14var globs = ['**/*.js', 'test/**/*'];15var normalizedGlobs = availableGlobs.normalizeGlobs(globs, {cwd: __dirname});16console.log(normalizedGlobs);17var availableGlobs = require('available-globs');18var globs = ['**/*.js', 'test/**/*'];19var normalizedGlobs = availableGlobs.normalizeGlobs(globs, {cwd: __dirname});20console.log(normalizedGlobs);21var availableGlobs = require('available-globs');22var globs = ['**/*.js', 'test/**/*'];23var normalizedGlobs = availableGlobs.normalizeGlobs(globs, {cwd: __dirname});24console.log(normalizedGlobs);

Full Screen

Using AI Code Generation

copy

Full Screen

1const ava = require('ava');2const glob = ava.normalizeGlobs('test/**/*.test.js');3console.log(glob);4const test = require('ava');5test('test', t => {6 t.pass();7});8const ava = require('ava');9const glob = ava.normalizeGlobs('test/**/*.test.js');10console.log(glob);11const test = require('ava');12test('test', t => {13 t.pass();14});15const test1 = require('ava');16test1('test1', t => {17 t.pass();18});19const ava = require('ava');20const glob = ava.normalizeGlobs('test/**/*.test.js');21console.log(glob);22const test = require('ava');23test('test', t => {24 t.pass();25});26const test1 = require('ava');27test1('test1', t => {28 t.pass();29});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ava automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful